Package org.apache.nutch.util
Class GZIPUtils
java.lang.Object
org.apache.nutch.util.GZIPUtils
A collection of utility methods for working on GZIPed data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final byte[]unzip(byte[] in) Returns an gunzipped copy of the input array.static final byte[]unzipBestEffort(byte[] in) Returns an gunzipped copy of the input array.static final byte[]unzipBestEffort(byte[] in, int sizeLimit) Returns an gunzipped copy of the input array, truncated tosizeLimitbytes, if necessary.static final byte[]zip(byte[] in) Returns an gzipped copy of the input array.
-
Constructor Details
-
GZIPUtils
public GZIPUtils()
-
-
Method Details
-
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
Returns 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
-