I have a log file which gets updated every second. I need to read the log file periodically, and once I do a read, I need to store the file pointer position at the end of the last line I read and in the next periodic read I should start from that point.
Currently, I am using a random access file in Java and using the getFilePointer()
method to get he offset value and the seek()
method to go to the offset position.
However, I have read in most articles and even the Java doc recommendations to use BufferredReader
for efficient reading of a file. How can I achieve this (getting the filepointer and moving to the last line) using a BufferedReader
, or is there any other efficient way to achieve this task?