在我的程序中要把zip中的文件解出来。
zip包里的文件名有中文。原程序如下。File f = new File("c:\照片.zip");
ZipFile Zf = new ZipFile(f);
Enumeration files = Zf.entries();
while (files.hasMoreElements()) {
ZipEntry tmpFile = (ZipEntry) files.nextElement();
String fileName = tmpFile.getName();
//输出的文件名是:????.jpg
System.out.println(tmpFile.getName()); FileOutputStream out = new FileOutputStream("c:\"+fileName );
//提示InputStream 空指针错误
InputStream in = Zf.getInputStream(tmpFile);
byte temp[] = new byte[65536];
int b = in.read(temp);
while (b >= 0) {
if (b == 0)
continue;
out.write(temp);
b = in.read(temp);
}
out.close();
in.close();
}
Zf.close();