Problem:
Environment: VSFTP + FTPClient + Client
Use FTPClient upload time is always jammed, and the file size is 0, upload failed,
solution:
Add code: Call FTPClient of enterLocalPassiveMode (); method, is set to passive mode, both can be resolved.
// use of FTPClient public void FTPClientTest () throws Exception { // create an object FTPClient FTPClient the FTP = new new FTPClient (); // 21 link ports used ftp.connect ( " 169.254.18.16 " , 21 ); // given user name and password and complete the registration link ftp.login ( " ftpuser " , " ftpuser " ); ftp.enterLocalPassiveMode (); // Upload a file InputStream IS = new new FileInputStream (" D: /java.jpg " ); // the specified directory to save the uploaded file ftp.changeWorkingDirectory ( " / Home / ftpuser / Casual " ); // open byte streaming ftp.setFileType (FTPClient.BINARY_FILE_TYPE); // file upload boolean b = ftp.storeFile ( " aa.jpg " , IS ); System. OUT .println (b); // Log ftp.logout (); }