I realise I forgot to include the method code I wrote to make it work
(even though I think people in here will find a better solution):
public static final byte[] unzipBestEffort(byte[] in, int sizeLimit)
{
try {
// decompress using GZIPInputStream
ByteArrayOutputStream outStream =
new ByteArrayOutputStream(EXPECTED_COMPRESSION_RATIO *
in.length);
GZIPInputStream inStream =
new GZIPInputStream ( new ByteArrayInputStream(in) );
int limit = sizeLimit;
if (sizeLimit < 0) {
limit = EXPECTED_COMPRESSION_RATIO * in.length;
}
byte[] buf = new byte[BUF_SIZE];
int written = 0;
while (true) {
try {
int size = inStream.read(buf);
if (size <= 0)
break;
if ((written + size) > limit) {
outStream.write(buf, 0, limit - written);
break;
}
outStream.write(buf, 0, size);
written+= size;
} catch (Exception e) {
break;
}
}
try {
outStream.close();
} catch (IOException e) {
}
return outStream.toByteArray();
} catch (IOException e) {
return null;
}
}
Regards,
S�bastien.
D�couvrez le nouveau Yahoo! Mail : 250 Mo d'espace de stockage pour vos mails !
Cr�ez votre Yahoo! Mail sur http://fr.mail.yahoo.com/
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Nutch-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nutch-general