We have a requirement that i should retrive latest data(information) from the log file.This log file will be updating ever 15 minutes.So when the user requested at particular time(say at 10.00AM),we should be able to get that data only.
On one small server I have a log writer that writes to a circular buffer in memory. Once it is full, the new entries overwrite the oldest. I don't know if you could afford the memory to build such a thing using age to grow and shrink the buffer - maybe a LinkedList - as time goes by. Here's a snippet from my workstation:
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
Note that when you use the skip() method to skip bytes, you generally need to use a loop to make sure that it really skips all the bytes you requested:
Depending on the operating system and how your logging works, you may or may not sometimes see a file that appears to end with an incomplete line, because the file is being written at the same time you're trying to read it. If you encounter this phenomenon, perhaps you can save the last line read in memory, and add it to whatever is read the next time you read the file. Or perhaps this in an unnecessary complication. You'll have to test and see what happens, I think.
"I'm not back." - Bill Harding, Twister
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop