Hi all,
I need to use a filter to manipulate the request body , my case is that i am having a compressed request , and i want to uncompress it and forward it to the
servlet , below is the method that handle the compressed data , any ideas?
public static final
String uncompress(final byte [] compressed) throws IOException{
String uncompressed = "";
try{
ByteArrayInputStream bais = new ByteArrayInputStream(compressed);
InflaterInputStream zis = new InflaterInputStream(bais);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int numBytesRead = 0;
byte [] tempBytes = new byte[DEFAULT_BUFFER_SIZE];
while ((numBytesRead = zis.read(tempBytes, 0, tempBytes.length)) != -1){
baos.write(tempBytes, 0, numBytesRead);
}
uncompressed = new String(baos.toByteArray());
}
catch (ZipException e){
e.printStackTrace();
}//catch
return uncompressed;
}//method
Regards,
Maher Dabbas.