Class GZIPUtils


  • public class GZIPUtils
    extends Object
    A collection of utility methods for working on GZIPed data.
    • Constructor Detail

      • GZIPUtils

        public GZIPUtils()
    • 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 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