Menu

#12 ZIF Extracting fails

open
nobody
None
5
2008-08-12
2008-08-12
No

i think there is a probleme with this method:

public static List unzip(InputStream is) {
List res = new ArrayList();
try {

ZipInputStream in = new ZipInputStream(is);
ZipEntry entry = null;
while ((entry = in.getNextEntry()) != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
stream.write(buf, 0, len);
}
InputStream isEntry = new ByteArrayInputStream(stream
.toByteArray());

File file = File.createTempFile("tmp", "_" + entry.getName());
copyInputStream(isEntry, new BufferedOutputStream(
new FileOutputStream(file)));
res.add(file);
}
in.close();
} catch (IOException e) {
logger.error(e.getMessage());
}
return res;
}
in windows environment, it can't creat temp file if there are directories inside zip file!

Discussion


Log in to post a comment.

MongoDB Logo MongoDB