- 论坛徽章:
- 0
|
源代码如下:
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 编辑 ] |
|