I am trying to read .log
file with over 2000 lines from the end to the start.
I can't use How to read file from end to start (in reverse order) in Java? , the file is to large.
Here is my code:
BufferedReader br = null;
try{
br = new BufferedReader(new FileReader(dataFile.getAbsolutePath())); // the log file
}catch(FileNotFoundException FNFE){
FNFE.printStackTrace();
}
And reading the file:
String line = null;
String lastLine = null;
while((line=br.readLine()) != null){
lastLine = line; //setting lastLine to the last line in the file
}
Is there a butter way to get this line?