Using a JFileChooser to allow a user to select a fileTopReview: Reading text from files

Review: Reading text from files

Last time we looked at code to read from a file. That code looked like this:

// create a stream to access dictionary file
fileReader = new BufferedReader(new FileReader(DICTIONARY_FILE));

// get the first line of the file
nextLine = fileReader.readLine();
			
// Read words until we run out of words or the array becomes full
while (nextLine != null) {
   // Code to process the line omitted

   // get the next line from the file
   nextLine = fileReader.readLine();
}

// Close the file
fileReader.close();

Using a JFileChooser to allow a user to select a fileTopReview: Reading text from files