It's been a while since I code in java and I'm having trouble trying to read a plain text file. Here's my code
private static ArrayList<String> readDict() {
BufferedReader br;
ArrayList<String> out = new ArrayList<String>();
try {
br = new BufferedReader(new FileReader("dict5.txt"));
String line;
while ((line = br.readLine()) != null) {
out.add(line);
}
} catch(Exception exc) {
System.out.println("Exception catched while reading file: " + exc);
} finally {
try {if (!br.isNull()) br.close();} catch(IOException exc) { System.out.println("IOException catched while closing file" + exc); }
}
return out;
}
br.isNull() gives me a compilation error, do you know why this is? Thank you in advance. The error: Main.java:30: error: cannot find symbol try {if (!br.isNull()) br.close();} catch(IOException exc) { System.out.println("IOException catched while closing file" + exc); } ^ symbol: method isNull() location: variable br of type BufferedReader 1 error error: compilation failed