I'm looking to read from a XML file which is stored within a zip file. I'm having TONs of issues understanding how to do this. The best I seem to be able to do is get an input stream working, BUT I CAN'T UNDERSTAND HOW TO READ IT! So I know that its the right file, no I want to pass the data to a XML parser I have. However I don't really understand what the input stream is, or how to manipulate it properly. I've seen it used before with a buffer and then reading into the buffer, my question with this is how do we properly choose the size of the buffer if it is a sufficiently large file?
Any help would be great, thanks!
ZipFile zf;
try {
zf = new ZipFile(directory);
CharBuffer charBuffer = CharBuffer.allocate(BUFFER_SIZE);
for (Enumeration<? extends ZipEntry> e = zf.entries();
e.hasMoreElements();) {
ZipEntry ze = e.nextElement();
String name = ze.getName();
if (name.endsWith(".xml")) {
InputStream in = zf.getInputStream(ze);
// read from 'in
}
}
} catch (IOException e1) {
System.out.println("Sorry we couldn't find the file");
e1.printStackTrace();
}