To read strings of text from a file we have to:
The Java statements that realize the three phases described above are:
// 1. opening the file for reading FileReader f = new FileReader("test.txt");; BufferedReader in = new BufferedReader(f); // 2. reading a line of text from the file String line = in.readLine(); // 3. closing the file f.close();
Notes: