reading a file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Living_Fossil
Posted On:   Monday, August 22, 2005 09:32 AM

i want to read a text file . that text file is getting updated with every 2 secs by an external program. in fact the text file is a log file of another program. i want to read the log file.i.e reading the last line .

i want to read the last line of the text file whenever i run my java code .

my problem is :

as the log file is updating every 2 secs so how do i read the file ?

i want as soon as i run my file reading code i get the latest last updated line .

How is it possible ?

Re: reading a file

Posted By:   Almagest_FUTT  
Posted On:   Wednesday, August 24, 2005 09:48 AM

I could think of two ways:

Most simple, since a living fossil like you definitely will use UNIX, is a /usr/bin/tail.

Else, i think you'll need to bestow the file size somewhere. You could then create an instance of RandomAccessFile, seek() to the last size, and read what has been added, if anything.
About | Sitemap | Contact