To help improve my proficiency with Java, I would like to know how should I close these FileReaders as I have come across multiple answers, and what could I do better with this block of code?
/**
* Returns a Vector<String> object that that can be parsed into classes.
* The file arugment must specify a realative or aboustle adress to the file.
* @param file to read
* @return
*/
public static ArrayList<String> read(File file) {
ArrayList<String> data = new ArrayList<String>();
String lineRead;
try {
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
while ( (lineRead = br.readLine()) != null ) {
data.add(lineRead);
}
br.close();
fr.close();
} catch(IOException e) {
e.printStackTrace();
}
return data;
}