I was asked in an interview how to read a very huge file ,the situation was suppose i have the ram size is 2GB but the file i need to read is of 5GB how this can be done effectively in java , i have searched on Google most of the solutions is to use buffered Reader . Can any body help me
public class BufferedReaderExample {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new FileReader("C:\\testing.txt")))
{
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Will this be effective or java provide some other in build functionality to do this