1
我正在寫一個程序從ftp下載文件,我希望文件被放置在工作目錄中的一個名爲「files」的文件夾中,但我不知道如何改變我的輸出流來做到這一點。保存一個文件相對於工作目錄
這裏是我的代碼:
String remoteFile1 = f.getName();
System.out.println(remoteFile1);
File downloadFile1 = new File(fileName);
OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
boolean success = client.retrieveFile(remoteFile1, outputStream1);
outputStream1.close();
if (success) {
System.out.println(fileName + " has been downloaded successfully.");
}
我不知道我需要編輯更改目錄哪一部分。
或'文件(「文件」,文件名)',它有時會比較有用;) – MadProgrammer
我沒有嘗試,但我得到的錯誤java.io.FileNotFoundException:文件/ Tul1D_diGly-K_r1.raw(沒有這樣的文件或目錄) – user2320239
@ MadProgrammer酷,感謝這個優雅的解決方案! –