Zstd解压错误-未知的帧描述符



我正在尝试用以下方式解压缩。zst文件:

public byte[] decompress() {
byte[] compressedBytes = Files.readAllBytes(Paths.get(PATH_TO_ZST));
final long size = Zstd.decompressedSize(compressedBytes);
return Zstd.decompress(compressedBytes, (int)size);
}

我遇到了这个

com.github.luben.zstd。[java] com.github.luben.zstd. zstddecompressctt . decompresbytearray (zstddecompressctt .java:157) [java] com.github.luben.zstd. zstddecompressctt .decompress(zstddecompressctt .java:214) [java]

有人遇到过类似的事情吗?谢谢!

这个错误意味着zstd不能识别帧的前4个字节。这可能是因为:

  1. 数据不是zstd格式,
  2. 在zstd帧的末尾有多余的数据。

您还需要检查Zstd.decompressedSize()的输出是否为0,这意味着帧已损坏,或者帧报头中没有显示大小。参考文档

public byte[] decompress() {
byte[] compressedBytes = Files.readAllBytes(Paths.get(PATH_TO_ZST));
final long size = Zstd.decompressedSize(compressedBytes);
byte[] deCompressedBytes = new byte[size];
Zstd.decompress(deCompressedBytes,compressedBytes);
return deCompressedBytes;
}

最新更新