Hi, I have an error file that keeps updating itself.By updating what i mean is whenever there is an error the error is written into the file.I need to read the file and display the output.If it is a static file than it is easy.The data inside the file is dynamic.I need to display the latest contents of the file.Eg - First I read the 5 lines of the file then the error file is updated then i have to read the updated contents and display. Does anyone have any idea about this.
If the old contents are replaced when a new error is added, you need to keep track of the last time you displayed it. Next time you check, only if its lastModifiedTime is larger than the value remembered, you display it again.
If the error messages are added at the end of the file, you need to keep track of how many lines of the files you have displyed so far. Next time you check, see if there are now more lines. If so, you only display the ones from the line you remembered to the last one.
You can check the file size now & then and get the part of the file added since last time with a RandomAccessFile starting one byte after the old size. One of the sherrifs had a neater solution to this a while back but I can't recall it right now. Maybe he'll come through for us again.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi