public void writeCompressString(String s) { if (s != null) { String compress; try { compress = GZipStrUtil.CompressString(s); } catch (IOException e) { DebugX.Log("dara writeCompressString ~" + e); compress = s; Debug.LogException(e); } if (s.Length > compress.Length) { Debug.Log(1.0f * compress.Length / s.Length + GZipStrUtil.DecompressString(compress)); // 压缩了 this.writeInt(1); this.writeString(compress); } else { // 没有压缩 this.writeInt(0); this.writeString(s); } } else { this.writeInt(0); this.writeInt(0); } }
public String getCompressString() { int compress = this.getInt(); String s = this.getString(); if (s == null || "".Equals(s)) { return(null); } if (compress == 1) { try { s = GZipStrUtil.DecompressString(s); } catch (IOException e) { DebugX.Log("dara getCompressString ~" + e); } } return(s); }