Duplicate :
|
|
Relates :
|
|
Relates :
|
A customer has pointed out on the java.net forums that opening a file on Windows using a FileInputStream causes other processes to be unable to delete the file. This is intended behavior as the code is currently written, as the sharing flags specified during the opening of the file are FILE_SHARE_READ and FILE_SHARE_WRITE. See io_util_md.c, fileOpen. However, Windows 2000 supplies a new flag, FILE_SHARE_DELETE, which allows another process to delete the file while it is still open. The customer would like to have this functionality available because they are parsing logs generated by another process and when the second process attempts to rotate its logs it can not delete the old log because the JVM has it open. There are really no convenient workarounds for this problem as all approaches ultimately involve using a FileInputStream at least briefly to get the current data from the log and if the target process attempts to delete the file while it is open it will be unable to do so. The associated thread is http://forums.java.net/jive/thread.jspa?threadID=2150&tstart=0
|