开发者社区> 问答> 正文

linux环境下下 FTPClient.retrieveFile() 下载稍大一点的文件就卡死了

FTPClient f = new FTPClient();   
    OutputStream out = null;
        f.connect(url,port);
          f.login(username, password);
          f.enterLocalPassiveMode();   //被动

         f.setControlEncoding("GBK");  
         f.setFileType(FTPClient.BINARY_FILE_TYPE);  
          f.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
        //f.setBufferSize(524288);
        //f.setSoTimeout(300000);     //  时间
        //f.setDataTimeout(300000);   //  时间
        f.changeWorkingDirectory(f.printWorkingDirectory()+ remotePath);   

        FTPListParseEngine engine = f.initiateListParsing(remotePath);
         FTPFile[] files = null;
        while (engine.hasNext()) {
            files = engine.getNext(25);  // "page size" you want
            for(FTPFile ff:files){   
                 if(ff.getName().equals(fileName)){   
                     File outfile = new File(localPath+"/"+newfilename);    
                     out = new BufferedOutputStream(new FileOutputStream(outfile));

                   logger.info(remotePath+"/"+ff.getName());
                    logger.info(remotePath+"/"+new String(ff.getName().getBytes("GBK"),"ISO-8859-1"));
                    boolean is = f.retrieveFile(remotePath+"/"+new String(ff.getName().getBytes("GBK"),"ISO-8859-1"), out);  

                     out.flush();
                     out.close(); 

                 }   
            }   

            i++;
        }
        f.logout();   
    下载一个 1kb的文件可以正常下载,说明权限是没问题的,9kb的文件就下载不了了,环境是linux+tomcat,   求教        
        另: windows环境下是正常的

展开
收起
杨冬芳 2016-07-11 18:26:12 4997 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
Alibaba Cloud Linux 3 发布 立即下载
ECS系统指南之Linux系统诊断 立即下载
ECS运维指南 之 Linux系统诊断 立即下载