Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

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

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic