0
我在嘗試使用Files.copy如果出現以下錯誤()方法:Files.copy()在Ubuntu拋出UnixException:沒有這樣的文件或目錄,即使文件存在
這是有問題的代碼:
public static void copyFile(File origin, File destinationDir)
{
if(!origin.exists())
return;
File destination = new File(destinationDir, origin.getName());
Logger.info("Copy File from: '" + origin.getAbsolutePath() + "' dest: '" + destination.getAbsolutePath() + "'");
try
{
Files.copy(origin.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
catch(IOException e)
{
e.printStackTrace();
}
}
我試圖複製該文件存在,我看了多次。相同的Java應用程序在Windows上使用相同的文件夾和文件結構。
操作系統,規格:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
這是應該被複制的文件:
您嘗試複製文件的文件夾是否存在? –
你如何運行? getcwd異常,它試圖確定當前的工作目錄 – Joni
我複製到的文件夾存在。我從ssh運行這個。我創建了一個屏幕會話並導航到存儲run.sh文件的文件夾添加。然後我通過「sh run.sh」執行它。有問題的行是「java -jar ../PPRPGServerUpdater.jar $ PWD gameServer」 – domisum