Commons-net FTPClient completePendingCommand()经常使程序死掉的原因分析以及解决方式
方法时需要特别注意,在调用这个接口后,一定要手动close掉返回的InputStream,然后再调用completePendingCommand方法,若不是按照这个顺序,则不对,伪代码:
- InputStream?is?=?ftpClient.retrieveFileStream(remote);
- is.close();ftpClient.completePendingCommand();
- File?localFile?=?new?File(localPath,?localFileName);
- OutputStream?output?=?new?FileOutputStream(localFile);ftpClient.retrieveFile(remoteFileName,?output);
- output.close();InputStream?input?=?new?FileInputStream(localFile);