赞
踩
最近需要使用到ftp传输,调用了FTPClient,但是在调用retrieveFileStream(remotename)方法时,发现当一次连接只下载一个文件没问题,但是一次连接下载多个文件时会出现空指针异常,查阅资料找到这些,整理如下做个记录:
/*
* You must close the InputStream when you
* finish reading from it. The InputStream itself will take care of
* closing the parent data connection socket upon being closed. To
* finalize the file transfer you must call
* {@link #completePendingCommand completePendingCommand } and
* check its return value to verify success.
*/
调用顺序:
in=ftpClient.retrieveFileStream(localFile.getName());
。。。。
in.close();
ftpClient.completePendingCommand();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。