我試圖使用以下方法中的代碼將在我的服務器中創建的一些文件複製到FTP。但奇怪的是我隨機獲得低於錯誤,我無法弄清楚發生了什麼。org.apache.commons.net.io.CopyStreamException:在複製時捕獲到IOException
Exception =org.apache.commons.net.io.CopyStreamException: IOException caught while copying.
以下是我將文件複製到FTP的代碼。
public void copyDumpsToFTP() throws SocketException, IOException
{
FTPClient f= new FTPClient();
f.connect(dumpProperties.getProperty("ftpIPAddress"));
boolean flag =f.login(dumpProperties.getProperty("ftpUser"),dumpProperties.getProperty("ftpPassword"));
System.out.println(" is connected to FTP ::"+flag);
// setting fileType to binary
boolean isFileTypeChanged =f.setFileType(FTP.BINARY_FILE_TYPE);
// System.out.println(" Is file type changed to binary :: "+isFileTypeChanged);
// change working directory of FTP Server
boolean isDirectoryChanged =f.changeWorkingDirectory(dumpProperties.getProperty("ftpDirectory"));
System.out.println(" Is the FTP working directory Changed :: "+isDirectoryChanged);
// to copy engineering dump from source to FTP
InputStream inputFileEngg = new FileInputStream(new File(dumpNameEngineering));
boolean isSavedEngg = f.storeFile(dumpProperties.getProperty("dumpNameOfEnggInFTP"), inputFileEngg);
System.out.println("is Engineering dump File Saved in FTP Server :: "+isSavedEngg);
System.out.println(" Engg Dump sucessfully Created and Saved in FTP...");
// to copy correspondance dump from source to FTP
InputStream inputFileCorr = new FileInputStream(new File(dumpNameCorrespondance));
boolean isSavedCorr = f.storeFile(dumpProperties.getProperty("dumpNameOfCorrInFTP"), inputFileCorr);
System.out.println("is Correspondance File Saved in FTP Server :: "+isSavedCorr);
System.out.println(" Correspondance Dump sucessfully Created and Saved in FTP...");
// to copy tmg dump from source to FTP
InputStream inputFileTmg = new FileInputStream(new File(dumpNameTmg));
boolean isSavedTmg = f.storeFile(dumpProperties.getProperty("dumpNameOfTmgInFTP"), inputFileTmg);
System.out.println("is TMG File Saved in FTP Server :: "+isSavedTmg);
System.out.println(" TMG Dump sucessfully Created and Saved in FTP...");
}
的程序執行,直到SOP聲明Is the FTP working directory Changed :: true
與上述後者,它已拋出錯誤。
看起來像一些'catch'塊是「有用的」壓制完整的堆棧跟蹤,這將包括根本原因。首先你需要修改代碼來打印完整的堆棧跟蹤並將其包含在你的帖子中(編輯帖子)。 – 2012-02-21 05:20:18