我有一个愚蠢的问题,我一直无法弄清楚。谁能帮我? 我的代码:尝试使用java.util.zip.ZipFile解压缩存档时出现FileNotFoundException
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。 我需要解压缩文件中的内容。 任何帮助在这里。
任何方式,我可以解决它,并感谢你队友 – Robin
最后我写了它为我的博客:http://thaparobin.blogspot .COM/2011/11/java的拆包-zip文件从 - 远程url.html – Robin