日期:2014-05-18 浏览次数:21086 次
public void releaseZipToFile(String sourceZip, String outFileName)
throws IOException {
ZipFile zfile = new ZipFile(sourceZip);
Enumeration zList = zfile.entries();
ZipEntry ze = null;
byte[] buf = new byte[1024];
while (zList.hasMoreElements()) {
ze = (ZipEntry) zList.nextElement();
if (ze.isDirectory()) {
continue;
}
OutputStream os = new BufferedOutputStream(new FileOutputStream(
getRealFileName(outFileName, ze.getName())));
InputStream is = new BufferedInputStream(zfile.getInputStream(ze));
int readLen = 0;
is.close();
os.close();
System.out.println("Extracted: " + ze.getName());
}
zfile.close();
File file = new File(sourceZip);
file.delete();
}
// ZipEntry e = createZipEntry(getUTF8String(b, 0, len));
ZipEntry e=null;
try
{
if (this.encoding.toUpperCase().equals("UTF-8"))
e=createZipEntry(getUTF8String(b, 0, len));
else
e=createZipEntry(new String(b,0,len,this.encoding));
}catch(Exception byteE) {
e=createZipEntry(getUTF8String(b, 0, len));
}