Reading file sizes over a network in Java. Windows problem?

Status
Not open for further replies.
I am sure the problem is related to this . I hav done heaps of testing and it has come down to this specific problem so I'm not rushing to conclusions here. Also a big thankyou for reading this.

I have a Java program that monitors log files. it does this by checking if the file has increased in size since it was last checked(ie. if lines were added the file would have got bigger). If the file has increased in size my program does its thing.

This works fine on the local machine(XP) but I also monitor log files on the network (win98). The problem is that the network machine reports that the log file on it has same file size all the time even if the file has increased in size. If I go to Windows Explorer it also shows the same size even if I refresh!

Get up and go to the macine where the log file is physically located and go to the files properties to read the exact file size (just looking at the file wont work) and suddenly the correct file size is sent to all the computers on the network. :mad: WTF!?!

I'm in a bit of a pickle here as you can see and if you are genius enough to figure it out or you have run across this before... well I can give you the satisfaction of being smarter than me :)

I know I could do it another way. I could repeatedly read the last line of the file and check if it changes but that HAS to be more inefficient than just checking the file size right?
 
Originally posted by EgalitarianBovine:
It seems that the info is getting cached and not updated properly.

This is hackish, but it might work. Try opening the file, closing it, and then checking the filesize. The act of opening it might cause it to update the file info.

-EB

That might well work but it would lose my place in the file (the end) and I would have to find it again. All that opening and closing couldnt be good for processing time either (this is a background app)

Thanks for the suggestion
 
Status
Not open for further replies.