Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read a text file which is being actively written to by another program  RSS feed

 
asaf david
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm running an application which writes info to a log file as it does it's thing
in my application, i need to monitor the progress by actively reading and parsing this log file

I tried using the lock mehod on nio file channel, each time locking a distinct part of the file which was already written, however when trying to actually read from the channel i'm getting -1 result, indicating that no bytes were found in the channel. i guess this is because the file wasn't properly closed yet.

can anyone provide code samples on how to read a text file which is being actively written to?

thanks in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!