My question is how to read file data from a zip, but actually, I have already implemented that part but the issue is I am having different files in zip (all xml) I don't want to parse those file using xml parser anyways I just want to read it, currently my code is reading all the xml files and I am appending all the data in one single String, How can I read and store different files data separately.
My Code-
public class unzipFile {
public static void main(String[] args) throws IOException {
String zipFileName = "people.zip";
StringBuilder s = new StringBuilder();
byte[] buffer = new byte[1024];
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName));
ZipEntry zipEntry;
int read;
while ((zipEntry = zis.getNextEntry())!= null) {
while ((read = zis.read(buffer, 0, 1024)) >= 0) {
s.append(new String(buffer, 0, read));
}
}
while (zipEntry != null){
zipEntry = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
System.out.println("Unzip complete");
System.out.println("S = "+s);
}
It will print all the data in one go from all the files, what should I need to change in order to read data of different files separately ? anyone please help me Thanks !