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线程的时候加锁
synchronized(ftpClientPool){
FTPClient ftpClient = ftpClientPool.createClient();
boolean success = upLoadFile(ftpClient,pathName,fileName,insComing);
if(!success){
System.out.println("imgUrl=" + js.getString("zytest"));
}
}
问题解决
顺便说下,storeFile还有中文编码问题,
fileName = new String(fileName.getBytes("UTF-8"),"iso-8859-1");
boolean tag = ftp.storeFile(fileName, in);