FTPClient - Java, upload file

后端 未结 8 934
遇见更好的自我
遇见更好的自我 2020-12-08 19:58

I\'m trying to do a VERY simple file upload. I want a Java FTPClient that can upload any file I tell it to. But the pdf always gets all messed up and my pdf editor (Adobe) w

相关标签:
8条回答
  • 2020-12-08 20:49

    Try to use BufferedInputStream, this is a (working) code sample:

    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
    res = client.storeFile("File Name", bis);
    bis.close();
    client.logout();
    
    0 讨论(0)
  • 2020-12-08 20:49

    Try this.

    objFtpClient.setFileType(FTP.BINARY_FILE_TYPE);
    
    objFtpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
    
    objFtpClient.enterLocalPassiveMode();
    
    0 讨论(0)
提交回复
热议问题