Skip to content
Snippets Groups Projects

fix: file not found exception

Merged Carl Gützkow requested to merge fix/file-exceptions into master
4 files
+ 20
6
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -7,10 +7,7 @@ import edu.ntnu.idatt2001.carljgu.units.specialized.CommanderUnit;
import edu.ntnu.idatt2001.carljgu.units.specialized.InfantryUnit;
import edu.ntnu.idatt2001.carljgu.units.specialized.RangedUnit;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.nio.file.FileSystems;
import java.nio.file.InvalidPathException;
@@ -55,9 +52,12 @@ public class FileHandler {
* @return army - Army - an army read from a csv file
* @throws FileExtensionException thrown if file extension is not csv
* @throws IOException thrown if an I/O error occurs
* @throws FileNotFoundException thrown if the filepath was not found
*/
public static Army readArmyFromFile(String filePath) throws FileExtensionException, IOException {
if (!filePath.startsWith(".csv", filePath.length() - 4)) throw new FileExtensionException("File extension has to be csv");
public static Army readArmyFromFile(String filePath)
throws FileExtensionException, IOException, FileNotFoundException {
if (!filePath.startsWith(".csv", filePath.length() - 4))
throw new FileExtensionException("File extension has to be csv");
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath))) {
String line;
Loading