I have a Zip that contains two files: an XML and a thumbnail. I would like to open the XML file and parse it WITHOUT having to extract on disk.
One of DocumentBuilder's parse method requires an InputStream. Is there a way to get the InputStream of the XML in the Zipped file? I kinda got lost. I'm pretty sure ZipInputStream or ZipFile has something to offer, but I can't figure it out :/
Thank you in advance!
You can use any modern browser to convert XML to ZIP, for example, Google Chrome, Firefox, Opera, Safari.
The .zip extension is the most common archive format utilised across the internet for storing a collection of files and directories in a single compressed file.
I believe you're looking for something like this:
FileInputStream fin = new FileInputStream("your.zip");
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
if (ze.getName().equals("your.xml")) {
// pass zin to DocumentBuilder
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With