Java GZIP 解压异常解决
异常1:
cn.hutool.core.io.IORuntimeException: EOFException: Unexpected end of ZLIB input stream
at cn.hutool.core.io.IoUtil.copy(IoUtil.java:190)
at cn.hutool.core.util.ZipUtil.unGzip(ZipUtil.java:736)
...
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at cn.hutool.core.io.IoUtil.copy(IoUtil.java:181)
异常2:
Exception in thread "main" cn.hutool.core.exceptions.UtilException: ZipException: Not in GZIP format
at cn.hutool.core.util.ZipUtil.unGzip(ZipUtil.java:738)
at cn.hutool.core.util.ZipUtil.unGzip(ZipUtil.java:707)
at com.bzcst.bop.charge.chr.model.aisino.AisinoBaseParam.main(AisinoBaseParam.java:137)
Caused by: java.util.zip.ZipException: Not in GZIP format
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:165)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:79)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:91)
at cn.hutool.core.util.ZipUtil.unGzip(ZipUtil.java:734)
... 2 more
原因是解压原文被篡改了,或者是编码格式不对,或者加了多余的空格