liuxiansheng

snappy-java-1.1.2.6.jar 版本用的这个

public static JSONArray decompress() {
List<MapValue> list = new ArrayList<MapValue>();
try {
byte[] contents = Files.toByteArray(new File(
"F:/spz/20161028145900.9.ttr.pack.spz"));
SnappyFramedInputStream is = new SnappyFramedInputStream(
new ByteArrayInputStream(contents));
 
int unLen = Snappy.uncompressedLength(contents);
ByteArrayOutputStream os = new ByteArrayOutputStream(unLen);
is.transferTo(os);
os.close();
byte[] re = os.toByteArray();
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(re);
 
while (unpacker.hasNext()) {
Value v = unpacker.unpackValue();
switch (v.getValueType()) {
case MAP:
MapValue map = v.asMapValue();
list.add(map);
break;
}
 
}
 
is.close();
 
} catch (Exception e) {
e.printStackTrace();
}
 
if (list != null && !list.isEmpty()) {
return JSONArray.parseArray(list.toString());
} else {
return null;
}
 
}
 
到标红那里解压结束 ,后面是msgpack反序列化.msgpack我用的是源码 jar发现不好使

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-10-14
猜你喜欢
  • 2022-02-09
  • 2022-12-23
  • 2021-12-14
  • 2021-07-31
  • 2021-06-17
  • 2022-02-21
相关资源
相似解决方案