// byte[] comp = new byte[numin - 4];
// System.arraycopy( b, (int)hoff, comp, 0, numin -4 );
// decompress the bytes
Inflater inf = new Inflater(false);
int resultLength;
int result = 0;
//byte[] inflateData = null;
byte[] tmp;
int uncompLen = 24500; /* length of decompress space */
byte[] uncomp = new byte[uncompLen];
inf.setInput(b, (int) hoff, numin - 4);
int limit = 20000;
while (inf.getRemaining() > 0) {
try {
resultLength = inf.inflate(uncomp, result, 4000);
}
catch (DataFormatException ex) {
System.out.println("ERROR on inflation " + ex.getMessage());
ex.printStackTrace();
throw new IOException(ex.getMessage());
}
result = result + resultLength;
if (result > limit) {
// when uncomp data larger then limit, the uncomp need to increase size
tmp = new byte[result];
System.arraycopy(uncomp, 0, tmp, 0, result);
uncompLen = uncompLen + 10000;
uncomp = new byte[uncompLen];
System.arraycopy(tmp, 0, uncomp, 0, result);
}
if (resultLength == 0) {
int tt = inf.getRemaining();
byte[] b2 = new byte[2];
System.arraycopy(b, (int) hoff + numin - 4 - tt, b2, 0, 2);
if (headerParser.isZlibHed(b2) == 0) {
System.arraycopy(b, (int) hoff + numin - 4 - tt, uncomp, result, tt);
result = result + tt;
break;
}
inf.reset();
inf.setInput(b, (int) hoff + numin - 4 - tt, tt);
}
}
/*
while ( inf.getRemaining() > 0) {
try{
resultLength = inf.inflate(uncomp);
}
catch (DataFormatException ex) {
System.out.println("ERROR on inflation");
ex.printStackTrace();
}
if(resultLength > 0 ) {
result = result + resultLength;
inflateData = new byte[result];
if(tmp != null) {
System.arraycopy(tmp, 0, inflateData, 0, tmp.length);
System.arraycopy(uncomp, 0, inflateData, tmp.length, resultLength);
} else {
System.arraycopy(uncomp, 0, inflateData, 0, resultLength);
}
tmp = new byte[result];
System.arraycopy(inflateData, 0, tmp, 0, result);
uncomp = new byte[(int)uncompLen];
} else {
int tt = inf.getRemaining();
byte [] b2 = new byte[2];
System.arraycopy(b,(int)hoff+numin-4-tt, b2, 0, 2);
if( headerParser.isZlibHed( b2 ) == 0 ) {
result = result + tt;
inflateData = new byte[result];
System.arraycopy(tmp, 0, inflateData, 0, tmp.length);
System.arraycopy(b, (int)hoff+numin-4-tt, inflateData, tmp.length, tt);
break;
}
inf.reset();
inf.setInput(b, (int)hoff+numin-4-tt, tt);
}
} */
inf.end();
int off;
byte b1, b2;
b1 = uncomp[0];
b2 = uncomp[1];