> I have a RandomAccessFile that I am writing to, but the modified time
> doesn't change when it is written to.
Try refreshing My computer, while the Thread is in sleep state.
As far as I know, if a process has a file open, no other process can
modify it. So if you java class has the file open, the OS process
cannot modify the modified date on the file. As a check, you can modify
the file multiple times between 5 second sleep intervals.
modifyFile(file, textToAppend);
close file
sleep code here
modifyFile(file, textToAppend);
close file
sleep code here
modifyFile(file, textToAppend);
close file
See if during sleep intervals, after closing the file, the date is
updated.
HalcyonWild - 30 Sep 2005 10:40 GMT
> As far as I know, if a process has a file open, no other process can
> modify it. So if you java class has the file open, the OS process
> cannot modify the modified date on the file.
What I meant is file is in read / write mode. Of course, you can open
two notepad instances, and play around with the files. I guess, notepad
doesnt keep the file open all the time. It opens, does the changes, and
closes the file when you Ctrl-S. Is that true.
Roedy Green - 30 Sep 2005 10:58 GMT
>It opens, does the changes, and
>closes the file when you Ctrl-S. Is that true.
Most editors don't lock the file except during the save. Word is an
exception.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
PilotYid - 30 Sep 2005 14:32 GMT
Well, the code I posted does not seem to update the modified time
unless the file is closed. I have a log file that a process is
periodically writing to and I would like to be able to tell when the
file is updated by looking at the modified time. Writing to the file
does not seem to do this with a RandomAccessFile, and using
setLastModified doesnt seem to work either. Any other ideas? Is this a
bug?
Thanks again
Aaron
Roedy Green - 30 Sep 2005 23:07 GMT
>Well, the code I posted does not seem to update the modified time
>unless the file is closed.
If you are trying to update the file time without closing it, you
need at the OS level a COMMIT. I don't know if a flush generates one.
It is worth a try.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
>Does a file have to be closed to use setLastModified() to change its
>modification date?
I think not (Try it to be sure. It won't explode.), but logically it
makes no sense to use it other than after closing since close has a
built in setLastModified( now ) (as part of the OS most likely). Any
setLastModified you did would be soon overwritten.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.