附加代码抛出 java.util.zip.ZipException:给定 .dat 文件的数据检查不正确

Attached code throws java.util.zip.ZipException: incorrect data check for given .dat file

我有一个使用 flate 编码的 dat 文件。 我正在尝试使用基于 ZLib 库的 InflateInputStream 解码该文件。 但是使用下面的示例给了我

     Exception in thread "main" java.util.zip.ZipException: incorrect data check

保留.dat 文件here

代码:-

    int buflength = 1;
    byte[] buf = new byte[buflength];
    FileInputStream is = new FileInputStream(new File(INPUT_DIRECTORY + INPUT_FILE));
    Inflater decompresser = new Inflater();
    //decompresser.setInput(buf);
    InflaterInputStream ifis = new InflaterInputStream(is,decompresser,buflength);



    FileOutputStream os = new FileOutputStream(new File(OUTPUT_DIRECTORY + OUTPUT_FILE));
    /*Deflater compressor = new Deflater();
    DeflaterOutputStream dfos = new DeflaterOutputStream(os, compressor, buflength);
    */

    int counter = 0;
    //long bytesToCopy = 40000;
    int bytesThisRead = 0;
    long bytesCopied = 0;

    while ((bytesThisRead = ifis.read(buf, 0, buf.length)) != -1) 
    {
        os.write(buf, 0, bytesThisRead);
        System.out.println((counter++) + " " + bytesThisRead);

        //bytesToCopy -= bytesThisRead;
        bytesCopied += bytesThisRead;
    }

我尝试调试 InflatterInputStream 库中的代码,在那里我发现读取原始数据流中的最后一个字节存在一些问题。 (将 buf 大小保持为 1,然后在最后一个字节后出现错误)

对于此数据文件,原始流的大小为 11005,而解码流的大小为 36963。

那么如何解决最后一个字节损坏的问题?

创建 zlib 流的人 (UL_obj_11_0_raw.dat) 并没有创建 zlib 流。末尾的Adler-32校验本来应该是big-endian顺序存储的,但是他们把正确的校验值存储错了,little-endian。