is it possible to get a zipentry's inputstream from a zipinputstream?
figured:
it's entirely possible, the call to ZipInputStream.getNextEntry()
positions the InputStream
at the start of the entry and therefore supplying the ZipInputStream
is the equivalent of supplying a ZipEntry
's InputStream
.
the ZipInputStream
is smart enough to handle the entry's EOF downstream, or so it seems.
p.
In addition to @pstanton post here is an example of code. I solved the problem using the following code. It was difficult to understand what the previous answer without an example.
//If you just want the first file in the zipped InputStream use this code.
//Otherwise loop through the InputStream using getNextEntry()
//till you find the file you want.
private InputStream convertToInputStream(InputStream stream) throws IOException {
ZipInputStream zis = new ZipInputStream(stream);
zis.getNextEntry();
return zis;
}
Using this code you can return an InputStream of the file that is zipped.