예제 #1
0
        /// <summary>
        ///   对ins进行GZip解压,输出到outs
        /// </summary>
        /// <param name="inStream"></param>
        /// <param name="outStream"></param>
        /// <returns></returns>
        public static void GZipDecompress(Stream inStream, Stream outStream)
        {
            var inGZipStream = new GZipStream(inStream, CompressionMode.Decompress, true);

            StdioUtil.CopyStream(inGZipStream, outStream);
            inGZipStream.Close();
        }
예제 #2
0
        /// <summary>
        ///   对ins解压,输出到outs
        /// </summary>
        /// <param name="inStream"></param>
        /// <param name="outStream"></param>
        /// <returns></returns>
        public static void Decompress(Stream inStream, Stream outStream)
        {
            var iis = new InflaterInputStream(inStream);

            StdioUtil.CopyStream(iis, outStream);
            iis.Close();
        }
예제 #3
0
        /// <summary>
        ///   对ins进行GZip压缩,输出到outs
        /// </summary>
        /// <param name="inStream"></param>
        /// <param name="outStream"></param>
        /// <returns></returns>
        public static void GZipCompress(Stream inStream, Stream outStream)
        {
            var gzipStream = new GZipStream(outStream, CompressionMode.Compress, true);

            StdioUtil.CopyStream(inStream, gzipStream);
            gzipStream.Close();
        }
예제 #4
0
        /// <summary>
        ///   对data从offset开始,长度为len进行GZip解压,输出到outs
        /// </summary>
        /// <param name="data"></param>
        /// <param name="offset"></param>
        /// <param name="length"></param>
        /// <param name="outStream"></param>
        /// <returns></returns>
        public static void GZipDecompress(byte[] data, int offset, int length, Stream outStream)
        {
            var inGZipStream =
                new GZipStream(new ByteInputStream(data, offset, length), CompressionMode.Decompress, true);

            StdioUtil.CopyStream(inGZipStream, outStream);
            inGZipStream.Close();
        }
예제 #5
0
        /// <summary>
        ///   对ins进行level级别压缩,输出到outs
        /// </summary>
        /// <param name="inStream"></param>
        /// <param name="level"></param>
        /// <param name="outStream"></param>
        /// <returns></returns>
        public static void Compress(Stream inStream, int level, Stream outStream)
        {
            var deflater = new Deflater();

            if (level >= 0 && level <= 9)
            {
                deflater.SetLevel(level);
            }
            var deflaterOutputStream = new DeflaterOutputStream(outStream, deflater, 4 * 1024);

            StdioUtil.CopyStream(inStream, deflaterOutputStream);
            deflaterOutputStream.Finish();
        }