0

I am trying to read a log file while it is being written to. I have tried using Scanner and RandomAccessFile and done a bit of searching but I can't find a way to get the read methods to block until there is new IO. Because of this I have to write sleeps/waits into the code but I keep hoping there is a better way?

Thanks.

casolorz
  • 8,486
  • 19
  • 93
  • 200
  • 1
    There is no other way. You must sleep and poll the file at intervals. – Jim Garrison Jul 02 '13 at 19:36
  • [This][1] may help you. Refer [this][2] one for more details. [1]: http://stackoverflow.com/questions/4149/how-do-i-use-java-to-read-from-a-file-that-is-actively-being-written [2]: http://stackoverflow.com/questions/4460221/read-a-file-while-its-being-written – Ruchira Gayan Ranaweera Jul 02 '13 at 19:45

0 Answers0