I am using FileReader wrapped in BufferedReader to read from 2 files, in case of an exception being thrown I want to know which file caused the error.
Is there a way of finding that out?
try (BufferedReader input1 = new BufferedReader(new FileReader(pathToFile1));
BufferedReader input2 = new BufferedReader(new FileReader(pathToFile2))){
// some more code here
} catch (FileNotFoundException e) {
System.err.println("File Not Found");
System.err.println(e.getMessage());
System.exit(2);
} catch (IOException e) {
System.err.println(e.getMessage());
System.exit(1);
Basically I want to know which file was not found and caused the first exception to be thrown.