0
問題是:接收來自FTP客戶端的空日誌文件,而連接到Azure的 - 因爲日誌是「使用」
FTPClient client = new FTPClient();
ofcourse我所有的連接細節在這裏和比:
InputStream inputStream = client.retrieveFileStream(file.getName());
System.out.println(client.getReplyString());
輸出:
550 The process cannot access the file because it is being used by
another process.
我怎樣才能把這個日誌文件?
下面是完整的代碼:
public static void retrieveLogFilesFTP() {
try {
FTPClient client = new FTPClient();
for (int i = 0; i < components.length; i++) {
client.connect(ENV_PROD);
client.login([loginUserName], [loginPassword]);
client.enterLocalPassiveMode();
client.setFileType(FTP.BINARY_FILE_TYPE);
client.changeWorkingDirectory("/site/wwwroot");
FTPFile[] ftpFiles = client.listFiles();
if (ftpFiles != null && ftpFiles.length > 0) {
for (FTPFile file : ftpFiles) {
if (file.getName().startsWith("httpplatform")) {
File currentDirectory = new File(PATH + components[i]);
if (!currentDirectory.exists()) {
currentDirectory.mkdir();
}
OutputStream output = new FileOutputStream(currentDirectory + "/" + file.getName(), false);
client.retrieveFile(file.getName(), output);
System.out.println(client.getReplyString());
output.close()
}
}
}
client.logout();
client.disconnect();
changeLogFilesNames(new File(PATH + "/" + components[i] + "/"), components[i]);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}