Commons-net FTPClient completePendingCommand()经常使程序死掉的原因分析以及解决方式_清风一池水的博客-CSDN博客
Commons-net FTPClient completePendingCommand()经常使程序死掉的原因分析以及解决方式
commons-net的FTPClient,在使用public InputStream retrieveFileStream(String remote)
方法时需要特别注意,在调用这个接口后,一定要手动close掉返回的InputStream,然后再调用completePendingCommand方法,若不是按照这个顺序,则不对,伪代码:
- InputStream is = ftpClient.retrieveFileStream(remote);is.close();ftpClient.completePendingCommand();
retrieveFileStream的API文档说的有点罗嗦,还可以使用下列方法来替换上述使用方式
使用一个中间文件来做一个转接,这种方式比上述方法的好处就是自己容易控制,不容易出问题。伪代码如下:
- File localFile = new File(localPath, localFileName);OutputStream output = new FileOutputStream(localFile);ftpClient.retrieveFile(remoteFileName, output);output.close();InputStream input = new FileInputStream(localFile);
关于原因这里有比较具体的分析: http://marc.info/?l=jakarta-commons-user&m=110443645016720&w=2
简单来说:completePendingCommand()会一直在等FTP Server返回226 Transfer complete,但是FTP Server只有在接受到InputStream执行close方法时,才会返回。所以先要执行close方法
关注
专栏目录
FTPClient中使用completePendingCommand方法时之踩坑
1703
1595
评论
写评论
Commons*-net* FTPClient *completePendingCommand(**)*经常…
6-10
java apache commons net_java – apache commons net – completependingcommand返回false
126
使用Apache Commons Net API实现FTP上传下载过程中的坑点
1万+
ftp下载完成后卡在ftpClient.completePendingCommand*(**)*;
6373
FTPClient 处理多个文件时注意添加completePendingCommand
热门推荐
1万+
ftp的**completePendingCommand方法
最新发布
387
该方法 ftpClient.completePendingCommand(**); 不可多加或者漏加,否则会导致程序卡死
commons*-*net FTPClient API存取设计
68
FTPClient中使用completePendingCommand方法注意事项
727
148
使用apache commons 2.0 net组件开发ftp上传大文件使**程序假死
234
commons net 下的FTPClient使用时的一些小问题
570
77
“相关推荐”对你有帮助么?
非常没帮助
没帮助
一般
有帮助
非常有帮助
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
400-660-0108
工作时间 8:30-22:00
©1999-2022北京创新乐知网络技术有限公司
码龄18年 暂无认证
97万+
访问
等级
1万+
积分
粉丝
51
获赞
114
评论
46
收藏
热门文章
- 关于UnsupportedOperationException异常
123303
- 使用import简化spring的配置文件
77769
- PreparedStatement的setNull
30541
- Commons-net FTPClient completePendingCommand()经常使程序死掉的原因分析以及解决方式
25241
- 给HTML下拉框选项添加背景色
21322
分类专栏
-
Substrate 1篇
-
Rust语言 1篇
-
ajax 8篇
-
css 1篇
-
DataBase 15篇
-
Eclipse 4篇
-
extremecomponents 2篇
-
GUI
-
Hibernate 33篇
-
http 1篇
-
J2EE 13篇
-
Java Article 35篇
-
javascript 2篇
-
LDAP
-
others 4篇
-
Portal&Portlet 1篇
-
Python 2篇
-
Reading
-
Regular Expression 2篇
-
Ruby 2篇
-
Software Engineering 2篇
-
Spring Framework 12篇
-
struts 4篇
-
struts2/webwork2 11篇
-
Tivoli 2篇
-
Version Control 2篇
-
web programming 4篇
-
Web(html,javascript,css,http) 10篇
-
weblogic 1篇
-
weblogic server 3篇
-
Flex 1篇
-
Web(html 4篇
-
mac 2篇
-
Mybatis 1篇
-
parallels 1篇
-
ubuntu 1篇
最新评论
- hibernte中用criteria实现not in功能的方法 sole.mjc: 我用这个操作 , 查询不出来数据
- javascript可以直接比较时间字符串的大小 Y Shy: 实际上比较的不是时间,而是从左到右逐位数字进行比较——如果比到最后还找不到大小不同的数字,则返回相等
- PreparedStatement的setNull 狐狸100: 如果不讲求速度,直接setObject是最为方便的
- hibernte中用criteria实现not in功能的方法 yyaosen: 扯淡
- javascript可以直接比较时间字符串的大小 东东小屋: “2019-08-07” > “2019-8-06” false
您愿意向朋友推荐“博客详情页”吗?
强烈不推荐
不推荐
一般般
推荐
强烈推荐
最新文章
- Build the Substrate Kitties Chain(中文翻译)
- Rust中模式守卫与@绑定的互换
- Parallels 10(v10.40) ubuntu desktop 14.04.4 无法安装Parallels tools
举报
拖拽到此处
图片将完成下载