I'm attempting to output a text file to the console with Java. I was wondering what is the most efficient way of doing so?
I've researched several methods however, it's difficult to discern which is the least performance impacted solution.
Outputting a text file to the console would involve reading in each line in the file, then writing it to the console.
Is it better to use:
Buffered Reader with a FileReader, reading in lines and doing a bunch of system.out.println calls?
BufferedReader in = new BufferedReader(new FileReader("C:\\logs\\")); while (in.readLine() != null) { System.out.println(blah blah blah); } in.close();
Scanner reading each line in the file and doing system.print calls?
while (scanner.hasNextLine()) { System.out.println(blah blah blah); }
Thanks.