Which option, when inserted at //INSERT CODE HERE, will enable method read()
in class Main to read and output its own source file?.
class Main{/*from w ww . jav a 2s. c o m*/ public void read() throws IOException{ File f = new File("Main.java"); FileReader fr = new FileReader(f); BufferedReader br = new BufferedReader(fr); String line = null; //INSERT CODE HERE System.out.println(line); br.close(); fr.close(); } }
readLine()
) != null)readLine()
) != null)readLine()
) != null)readLine()
) != -1)readLine()
) != -1)readLine()
) != -1)a
Method readLine()
isn't defined in classes File and FileReader.
It's defined only in class BufferedReader.
Also, readLine()
returns null if the end of the stream has been reached.