0
我試圖從服務器中提取zip文件(一個zip文件是在server.so我想提取通過FTP),我使用此代碼,FTP zip文件提取錯誤
byte[] buf = new byte[1024];
ZipInputStream zinstream = new ZipInputStream(Home.ftpClient.retrieveFileStream("HO2BR.br.3162675983055490721.zync"));
ZipEntry zentry = zinstream.getNextEntry();
System.out.println("Name of current Zip Entry : " + zentry + "\n");
while (zentry != null) {
String entryName = zentry.getName();
System.out.println("Name of Zip Entry : " + entryName);
FileOutputStream outstream = new FileOutputStream(entryName);
int n;
while ((n = zinstream.read(buf, 0, 1024)) > -1) {
outstream.write(buf, 0, n);
}
System.out.println("Successfully Extracted File Name : " + entryName);
outstream.close();
zinstream.closeEntry();
zentry = zinstream.getNextEntry();
}
zinstream.close();
}
ZipInputStream(Home.ftpClient.retrieveFileStream(「HO2BR.br.3162675983055490721.zync」)); 到輸入流分配FTPClient的retrieveFileStream
在執行時出現此錯誤
java.util.zip.ZipException程序:無效的距離太遠 在java.util.zip。 InflaterInputStream.read(InflaterInputStream.java:164)
我該如何解決這個異常?
嗨,可以從服務器提取壓縮文件,我的意思是沒有下載文件,我需要提取到服務器。 – 2013-02-16 04:29:59