【发布时间】:2011-11-04 05:30:12
【问题描述】:
我有一个我无法弄清楚的愚蠢问题。谁能帮我? 我的代码如下:
String zipname = "C:/1100.zip";
String output = "C:/1100";
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
ZipFile zipFile = new ZipFile(zipname);
Enumeration<?> enumeration = zipFile.entries();
while (enumeration.hasMoreElements()) {
ZipEntry zipEntry = (ZipEntry) enumeration.nextElement();
System.out.println("Unzipping: " + zipEntry.getName());
bis = new BufferedInputStream(zipFile.getInputStream(zipEntry));
int size;
byte[] buffer = new byte[2048];
它不会创建文件夹,但调试会显示所有正在生成的内容。 为了创建一个文件夹,我使用了代码
if(!output.exists()){ output.mkdir();} // here i get an error saying filenotfoundexception
bos = new BufferedOutputStream(new FileOutputStream(new File(outPut)));
while ((size = bis.read(buffer)) != -1) {
bos.write(buffer, 0, size);
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
bos.flush();
bos.close();
bis.close();
}
我的 zip 文件包含图像:a.jpg b.jpg... 在同一层次结构中,我有 abc.xml。 我需要按原样提取 zip 文件中的内容。 这里有任何帮助。
【问题讨论】:
标签: java unzip filenotfoundexception