当前位置:   article > 正文

FTPClient storeFile返回false,报550-The process cannot access the file because it is being used by anoth_ftpclient.storefile返回false解决方法

ftpclient.storefile返回false解决方法
boolean tag = ftp.storeFile(fileName, in);

返回false,断点进去看replyString:550-The process cannot access the file because it is being used by another process. 
 Win32 error:   The process cannot access the file because it is being used by another process. 
 Error details: File system returned an error.
550 End

意思是线程被占用,

解决方法,在创建FTP线程的时候加锁

  1. synchronized(ftpClientPool){
  2. FTPClient ftpClient = ftpClientPool.createClient();
  3. boolean success = upLoadFile(ftpClient,pathName,fileName,insComing);
  4. if(!success){
  5. System.out.println("imgUrl=" + js.getString("zytest"));
  6. }
  7. }

问题解决

顺便说下,storeFile还有中文编码问题,

  1. fileName = new String(fileName.getBytes("UTF-8"),"iso-8859-1");
  2. boolean tag = ftp.storeFile(fileName, in);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/215964
推荐阅读
相关标签
  

闽ICP备14008679号