Unity BZip2压缩和解压,基于C#
?
壓縮和解壓代碼舉例:
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));
轉(zhuǎn)載于:https://www.cnblogs.com/peiandsky/archive/2012/05/08/2489568.html
總結(jié)
以上是生活随笔為你收集整理的Unity BZip2压缩和解压,基于C#的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 推荐几个Linux命令行下性能监控小工具
- 下一篇: Linux 串口编程分析