posted 13 years ago
Thanks,
But I was trying to decompress(unzip) using the follwoing code. But it didnt even work out. I post the zipped xml file thought POST request.
final int BUFFER = 2048;
StringBuilder xmlData = new StringBuilder();
try{
ZipInputStream zis = new ZipInputStream(request.getInputStream());
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
System.out.println("Extracting: " + entry);
int count;
byte data[] = new byte[BUFFER];
while ((count = zis.read(data, 0, BUFFER)) != -1) {
xmlData.append(data);
}
}
}catch(Exception e)
{
}
The problem is, the code is not getting in to the while loop. I believe the ZipInputStream is not taking the request.getInputStream(). I tried to pass the zipped file like ,
FileInputStream fis = new FileInputStream(
"c:\\TEST\\unit_test2_zip.zip");
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(fis));
It was working good. Tried to put the same logic by request.getInputStream(). It failed. Should I need to do like identifying the compressed format and proceed? Any solution ?
Thanks,
SXP