Most efficient way to tail/poll a log file in Java [duplicate]
This question already has answers here : In Java, what is the best/safest pattern for monitoring a file being appended to? (7 answers) There are many approaches, one could use create a Program and just call the Unix tail command, however the problem with this is that the process must be installed on a Unix machine with tail installed. The other option is to just read the file, line by line until there are no more lines, sleep for a period of time and then try to read the next line and repeat. The question is what/how do I go about polling a file which is actively being written to. AFAIK there