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

  Modifier and Type
  Method
  Description
  `static 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 to `sizeLimit` bytes, if necessary.
  `static final byte[]`
  `zip(byte[] in)`
  Returns an gzipped copy of the input array.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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 extracted `null` is 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 to `sizeLimit` bytes, 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 extracted `null` is returned.
    Parameters:
      `in` - Byte array to gunzip
      `sizeLimit` - Maximum size allowed for gunzipped byte array
    Returns:
      the gunzipped byte array, or null

  - ### unzip

    public static final byte[] unzip(byte[] in) throws IOException
    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