ZipEntry to InputStream or java.io.File. How?
Hi,
I've spent many hours trying to find a solution to this problem, but all in vain.
Here's the deal:
I have a ZipInputStream, which I've even managed to get a ZipEntry from.
I can get the size or the name of this entry. The entry itself is an XML file which I need to get access to,
but how can I do that without a ZipFile instance?
Here's my code so far:
Code :
ByteArrayInputStream bais = new ByteArrayInputStream(zipBytes);
ZipInputStream zis = new ZipInputStream(bais);
ZipEntry ze = zis.getNextEntry();
I need to extract the entry as InputStream or java.io.File to pass it to a DocumentBuilder and parse the XML.
Any ideas?
thanks.
Re: ZipEntry to InputStream or java.io.File. How?
After you get the ZipEntry have you tried reading from the ZipInputStream to read its data?
Read the API doc for the getNextEntry() method.
Re: ZipEntry to InputStream or java.io.File. How?
Yeah, I did it..
I seem to have found the problem, it's my overtiredness. I forgot the XML file is XOR encrypted, that's why it can't read it
Re: ZipEntry to InputStream or java.io.File. How?
Well, I was wrong, the encryption was not a problem.
I cannot even get the size of the entry. It always returns -1.
I've managed to google out that it's because the size is written after the entry.
Like I can easily get it from ZipFile, but the problem is that I don't have a zip file, I only have a ZipInputStream..
It there any workaround to it?
Re: ZipEntry to InputStream or java.io.File. How?
For testing try creating a zip file in a byte array and then getting a ZipInputStream on that and reading from it. Then post the code here if you can't get it to work.