I'm trying to rename a file which I have access by RandomAccessFile. When I do all changes I want in the temporary archive, I close the two RAF. But when I try to move the file, to rename(replacing) it says that my archives are been used by other process.
When the application is running I can't do nothing with the archive manually, but when the application closes, I can do anything that I want.
newraf.close();
raf.close();
File temp = new File(userHome+"\\orig.temp");
File orig = new File(userHome+"\\orig.ejb");
Files.move(temp.toPath(), orig.toPath(), REPLACE_EXISTING );
I tried using other manner, but didn't worked:
newraf.close();
raf.close();
File temp = new File(userHome+"\\orig.temp");
File orig = new File(userHome+"\\orig.ejb");
temp.renameTo(orig);
I saw this, but didn't help too much.