j_alen 2015-06-02 01:22 采纳率: 0%
浏览 7230

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环境下是正常的
  • 写回答

3条回答

  • 一枪尽骚丶魂 2015-06-02 01:31
    关注

    下载大小应该可以设置吧

    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式