类 GzipUtils

java.lang.Object
com.dtflys.forest.utils.GzipUtils

public class GzipUtils extends Object
GZIP工具类
从以下版本开始:
1.5.1
作者:
gongjun[jun.gong@thebeastshop.com]
  • 构造器详细资料

    • GzipUtils

      public GzipUtils()
  • 方法详细资料

    • isGzip

      public static boolean isGzip(String contentEncoding)
      判断是否为gzip

      根据Response传回的Content-Encoding来判断是否为gzip压缩的内容

      参数:
      contentEncoding - 内容编码
      返回:
      true为gzip压缩内容, 否则不是
    • compressGzip

      public static byte[] compressGzip(byte[] bytes)
      压缩字节数组数据
      参数:
      bytes - 字节数组数据
      返回:
      压缩过的字节数组
    • compressGzip

      public static byte[] compressGzip(String text, Charset charset)
      压缩字符串数据
      参数:
      text - 字符串数据
      charset - 字符集
      返回:
      压缩过的字节数组
    • compressGzip

      public static byte[] compressGzip(String text)
      压缩字符串数据
      参数:
      text - 字符串数据
      返回:
      压缩过的字节数组
    • decompressGzipInputStream

      public static GZIPInputStream decompressGzipInputStream(InputStream in) throws IOException
      将InputStream转换为GZIPInputStream
      参数:
      in - InputStream实例
      返回:
      GZIPInputStream实例
      抛出:
      IOException - IO异常
    • decompressGzipToByteArray

      public static byte[] decompressGzipToByteArray(GZIPInputStream gzipIn) throws IOException
      将GZIP输入流解压为字节数组
      参数:
      gzipIn - GZIPInputStream实例
      返回:
      字节数组
      抛出:
      IOException - IO异常
    • decompressGzipToString

      public static String decompressGzipToString(GZIPInputStream gzipIn, String encoding) throws IOException
      将GZIP输入流解压为字符串
      参数:
      gzipIn - GZIPInputStream实例
      encoding - 字符串编码
      返回:
      字符串
      抛出:
      IOException - IO异常
    • decompressGzipToByteArray

      public static byte[] decompressGzipToByteArray(InputStream in) throws IOException
      将GZIP输入流解压为字节数组
      参数:
      in - InputStream实例
      返回:
      字节数组
      抛出:
      IOException - IO异常
    • decompressGzipToString

      public static String decompressGzipToString(InputStream in, String encoding) throws IOException
      将GZIP输入流解压为字符串
      参数:
      in - InputStream实例
      encoding - 字符串编码
      返回:
      字符串
      抛出:
      IOException - IO异常
    • decompressGzipToString

      public static String decompressGzipToString(byte[] bytes, String encoding) throws IOException
      将GZIP输入流解压为字符串
      参数:
      bytes - 字节数组
      encoding - 字符串编码
      返回:
      字符串
      抛出:
      IOException - IO异常