File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Tailing  a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Tailing  a file" Watch "Tailing  a file" New topic

Tailing a file

Yaroslav Chinskiy
Ranch Hand

Joined: Jan 09, 2001
Posts: 147
What is the best way to tail a file?
I can write a thread that checks the file every 5sec and if new line is writen, then will notify, but how do you do it without a sleep.
Vector lines = new Vector();
if ((record = logReader.readLine()) == null){
if(record.length() == 0){

}catch(InterruptedException ie){
new ExceptionHandler(ie);
}catch(IOException ioe){
new ExceptionHandler(ioe);
}catch(IOException ioe){}

Thank you.
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
Take a look at this link - maybe it will help:
I agree. Here's the link:
subject: Tailing a file
It's not a secret anymore!