I have servlet to read log file my jsp call servlet at some interval.I want to add functionality in my servlet so that it read file from line next to last line from previous read.
I have following code but its not working
File file = new File("D:\\graph\\temp.log");
FileReader fr = new FileReader(file);
LineNumberReader lnr = new LineNumberReader(fr);\
lnr.setLineNumber(count) // count is the variable keeping track of number of line
previously read.
Is it need some extra code ? or is there any other alernative to do the same ?
From the documentation:
Sounds to me like you’ll have to start from the beginning and call readLine in a loop until getLineNumber() is greater than count.
Something like this: