2012-02-21 44 views
1

私のサーバーで作成されたいくつかのファイルを以下の方法でコードを使用して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

まで実行しており、前述したように、後者はエラーを投げていました。

+2

いくつかの 'catch'ブロックは根本的な原因を含む完全なスタックトレースを"有益に "抑制しているようです。まず最初にすべきことは、完全なスタックトレースを出力してそれをあなたのポストに含める(ポストを編集する)コードを修正することです。 –

答えて

0

変更しているディレクトリは同じパスに存在する必要があり、FTPが書き込むことができるように適切な書き込み権限が必要です。ディスク容量が見積もりを超えて利用できるまたはディスクでないとき

はここに...

boolean isDirectoryChanged =f.changeWorkingDirectory(dumpProperties.getProperty("ftpDirectory")); 
0

このエラーが発生しました。

関連する問題