zoukankan      html  css  js  c++  java
  • Unity BZip2压缩和解压,基于C#

    1. 基于BZip2的压缩方式(ICSharpCode.SharpZipLib

     

    压缩和解压代码举例:

    MemoryStream ms = new MemoryStream();

            BZip2OutputStream zlib = new BZip2OutputStream(ms);

            byte[] src = Encoding.UTF8.GetBytes("#¥%……%……&@");

            zlib.Write(src, 0, src.Length);

            zlib.Close();

            byte[] press = ms.ToArray();

            Debug.Log(Convert.ToBase64String(press) + " " + press.Length);

     

            BZip2InputStream gzi = new BZip2InputStream(new MemoryStream(press));

            MemoryStream re = new MemoryStream();

            int count = 0;

            byte[] data = new byte[4096];

            while ((count = gzi.Read(data, 0, data.Length)) != 0)

            {

                re.Write(data, 0, count);

            }

            byte[] depress = re.ToArray();

     

            Debug.Log(Encoding.UTF8.GetString(depress));

  • 相关阅读:
    5 November
    31 October
    K-th Path
    P1525 关押罪犯
    dp-棋盘形dp
    P1462 通往奥格瑞玛的道路
    noip2017部分题目
    洛谷orz--尺取法
    树形dp
    最短路练习
  • 原文地址:https://www.cnblogs.com/peiandsky/p/2489568.html
Copyright © 2011-2022 走看看