【问题标题】:org.apache.commons.net.io.CopyStreamException: IOException caught while copyingorg.apache.commons.net.io.CopyStreamException:复制时捕获 IOException
【发布时间】:2022-04-09 14:00:50
【问题描述】:

我正在尝试使用以下方法中的代码将在我的服务器中创建的一些文件复制到 FTP。但奇怪的是我随机低于错误,我无法弄清楚发生了什么。

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 块“有帮助”抑制了完整的堆栈跟踪,这将包括根本原因。您需要做的第一件事是修改代码以打印完整的堆栈跟踪并将其包含在您的帖子中(编辑帖子)。
  • 否则您自己未能提供完整的堆栈跟踪,仅包含秘密原因。
  • 使用 Apache FTPClient 时出现同样的错误。找不到解决方案

标签: java


【解决方案1】:

您要更改的目录应该存在于同一路径上,并且应该具有适当的写入权限,以便 FTP 可以对其进行写入。

这里...

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

【讨论】:

    【解决方案2】:

    当磁盘空间不可用或磁盘引用超出时发生此错误。

    【讨论】:

    • 或者其他的。
    【解决方案3】:

    遇到这个问题的时候,要登陆的ftp服务器的磁盘空间已经满了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-29
      • 2015-10-09
      • 2012-12-19
      • 2018-02-10
      • 2011-03-14
      • 2012-10-18
      • 2012-11-02
      • 2017-05-24
      相关资源
      最近更新 更多