且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java.nio.file.FileSystemException:进程无法访问该文件,因为它正被另一个进程使用

更新时间:2023-01-31 16:37:06

好的,我没有找到完美的解决方案,但有些东西......

Ok, I don't found a perfect solution but something...

try {
        //Files.move(fileToBeInstalled.toPath(), installPathFile.toPath(), REPLACE_EXISTING);
        Files.copy(fileToBeInstalled.toPath(), installPathFile.toPath(), REPLACE_EXISTING);
        fileToBeInstalled.delete();
} catch (IOException ex) {
    MainClass.getMainClass(InstallerLinux.class.getName()).log(Level.SEVERE, null, ex);

}

此文件正确复制并仅在 linux 执行时正确擦除原始文件.

This copy correctly the file and erases correctly the original only on linux execution.

我认为要做到这一点,我需要使用类加载器调用该类..

I think for do that I need to invoke the class using a class loader..