Package org.apache.nutch.util
Class GZIPUtils
- java.lang.Object
-
- org.apache.nutch.util.GZIPUtils
-
public class GZIPUtils extends Object
A collection of utility methods for working on GZIPed data.
-
-
Constructor Summary
Constructors Constructor Description GZIPUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]unzip(byte[] in)Returns an gunzipped copy of the input array.static byte[]unzipBestEffort(byte[] in)Returns an gunzipped copy of the input array.static byte[]unzipBestEffort(byte[] in, int sizeLimit)Returns an gunzipped copy of the input array, truncated tosizeLimitbytes, if necessary.static byte[]zip(byte[] in)Returns an gzipped copy of the input array.
-
-
-
Method Detail
-
unzipBestEffort
public static final byte[] unzipBestEffort(byte[] in)
Returns an gunzipped copy of the input array. If the gzipped input has been truncated or corrupted, a best-effort attempt is made to unzip as much as possible. If no data can be extractednullis returned.- Parameters:
in- byte array to gunzipped- Returns:
- the gunzipped byte array, or null
-
unzipBestEffort
public static final byte[] unzipBestEffort(byte[] in, int sizeLimit)Returns an gunzipped copy of the input array, truncated tosizeLimitbytes, if necessary. If the gzipped input has been truncated or corrupted, a best-effort attempt is made to unzip as much as possible. If no data can be extractednullis returned.- Parameters:
in- Byte array to gunzipsizeLimit- Maximum size allowed for gunzipped byte array- Returns:
- the gunzipped byte array, or null
-
unzip
public static final byte[] unzip(byte[] in) throws IOExceptionReturns an gunzipped copy of the input array.- Parameters:
in- Byte array to gunzip- Returns:
- the gunzipped byte array
- Throws:
IOException- if the input cannot be properly decompressed
-
zip
public static final byte[] zip(byte[] in)
Returns an gzipped copy of the input array.- Parameters:
in- Byte array to zip- Returns:
- the zipped byte array
-
-