免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4257 | 回复: 0
打印 上一主题 下一主题

java读取ftp上zip文件报错,求助。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-06 23:13 |只看该作者 |倒序浏览
源代码如下:
        public boolean previewOrGroupSendMail(String remotePath){
                boolean successFlag = false;
                InputStream is = null;
                ArrayList list = new ArrayList();
                FtpClient ftpClient = new FtpClient();
                GeneralXmlParser paser = new GeneralXmlParser();
                String path = FileTool.getFilePathFromPath(remotePath);
                String filename = FileTool.getFileNameFromPath(remotePath);
                if(path.equals("") || filename.equals("")){
                        return successFlag;
                }
                try {
                       
                        ftpClient.openServer(FtpServer);
                        ftpClient.login(FtpUser, FtpUserPwd);
                        if (path.length() != 0)
                                ftpClient.cd(path);
                        ftpClient.binary();
                        TelnetInputStream tis = ftpClient.get(filename);
                        is = new DataInputStream(tis);
                        ZipInputStream zin = new ZipInputStream(is);       
                        ZipEntry ze;
                        int num = 0;
                        while((ze = zin.getNextEntry()) != null){
                                System.out.println(ze.getName());
                                if (ze.isDirectory()) {
                                        continue;
                                } else {
                                        num ++;
                                        list = paser.XMLToList(zin);//处理zip文件中当前文件的数据流
                                        SendThread thread = new SendThread(list,false);
                                        MainServlet.j++;
                                        thread.start();
                                        list = null;
                                        while(MainServlet.j >= Integer.parseInt(PropertyManager.getProperty("TMAXTHREADNUM"))){
                                                Thread.sleep(Integer.parseInt(PropertyManager.getProperty("TSLEEPTIME"))*1000);
                                                System.out.println("线程sleep结束.当前是第"+(num)+"个文件,计数器的值是"+MainServlet.j);
                                        }
                                        successFlag = true;
                                }
                        }
                } catch (IOException ex) {
                        ex.printStackTrace();
                } catch (NumberFormatException e) {
                        e.printStackTrace();
                } catch (InterruptedException e) {
                        e.printStackTrace();
                } finally{
                        try {
                                is.close();
                                ftpClient.closeServer();
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }
                return successFlag;
               
        }




报错信息:
java.io.IOException: Stream closed
        at java.util.zip.ZipInputStream.ensureOpen(ZipInputStream.java:43)
        at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:67)
        at com.wondertek.util.FtpTool.previewOrGroupSendMail(FtpTool.java:152)
        at com.wondertek.util.FtpTool.main(FtpTool.java:200)
sun.net.ftp.FtpProtocolException: Error reading FTP pending reply

        at sun.net.ftp.FtpClient.issueCommand(FtpClient.java:189)
        at sun.net.ftp.FtpClient.closeServer(FtpClient.java:168)
        at com.wondertek.util.FtpTool.previewOrGroupSendMail(FtpTool.java:179)
        at com.wondertek.util.FtpTool.main(FtpTool.java:200)

报错在while((ze = zin.getNextEntry()) != null){处,请高手解答。急!!!

[ 本帖最后由 mj217 于 2007-3-6 23:15 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP