class LogReader {
public void readLogFile(String path){
BufferedReader br = new BufferedReader(new FileReader(path));
String currentLine=null;
while(currentLine=br.readLine()!=null){
System.out.println(currentLine);
}
}
}
Imagine I have a log file worth several 100 Megs. Will the above code load the entire file in memory ? If so what is the real benefit of buffering here ?
I am reading File I/O and not able to grasp the idea of whether we will load the bytes worth a line (currentLine) above in the memory or the whole file gets into memory and then each line gets read and assigned to the variable in memory again.
Please tell me the way I can avoid loading the entire file in memory if this is not the way.