Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a file  RSS feed

 
Yaroslav Chinskiy
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a thread to constantly read a file content
it checks for update every 5 sec (i use sleep)
Is there a better way to tail a file.
Also i user aborts a program how do i make sure that fileReader is closed?
Thank you.
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Check out the Observer pattern in the Design Patterns Books. It is helpful in what you want to do. Basically it is just like the jave Event model where in there is a listener which invokes a method on an Event.
For example in your case if you change the file in any way maybe you can raize an event.
------------------
Regds.
Mahindrakar
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!