Hi,
I would like to rename file, but File.renameTo() will not work if the file will be locked by some other process. If other process has locked the file, I would like to wait for it to release the lock. So I have:
FileLock lock = new RandomAccessFile(file, "rw").getChannel().lock(0L, Long.MAX_VALUE, false);
file.renameTo(destFile);
lock.release();
But this does not work, because file is locked and renameTo does not work (returns false).
What can I do to lock the file myself (wait for other locks to be released) and to rename it (rename does not work when file is locked).
Regards
Pawel Stawicki