What is the difference between these 2 methods used to read characters from a file.
FIRST
FileReader fr = new FileReader( new File( "file.txt") );
int x = 0;
while( ( x = fr.read() ) != -1 ) {
System.out.println( (char) x );
}
SECOND
BufferedReader bfr = new BufferedReader( new FileReader( new File( "file.txt") ) );
int x = 0;
while( ( x = bfr.read() ) != -1 ) {
System.out.println( (char) x );
}
Both the codes read the characters from the file and write it on the console.
Which one of the method is more efficient and why ? Or it’s the same thing ?
Thus spake the docs: