小编Kat*_*vel的帖子

在java中使用ftp下载时文件被损坏

当我尝试提取压缩文件时,文件被损坏。这是我使用过的代码。我无法理解我出了什么问题。文件的格式是.zip,里面有XML文件。从远程服务器下载后,XML 文件标签发生更改并且看起来已损坏。

public Boolean pullConfirmationsFTP(String host, String sftpUserName, String sftpPwd,
      String sftpPort, String fromConfirmationDirectory, String archiveConfirmationDirectory,
      String toDirectory) {
    try {

      // new ftp client
      FTPClient ftp = new FTPClient();
      // try to connect
      ftp.connect(host);
      // login to server
      if (!ftp.login(sftpUserName, sftpPwd)) {
        ftp.logout();
        LOG4J.error("Authentication failed");
      }
      int reply = ftp.getReplyCode();
      // FTPReply stores a set of constants for FTP reply codes.
      if (!FTPReply.isPositiveCompletion(reply)) {
        ftp.disconnect();
      }

      // enter passive mode
      ftp.enterLocalPassiveMode();

      // get system name
      // System.out.println("Remote system is …
Run Code Online (Sandbox Code Playgroud)

java ftp file-transfer

2
推荐指数
1
解决办法
1815
查看次数

标签 统计

file-transfer ×1

ftp ×1

java ×1