首页 新闻 会员 周边

今天发现有段代码报错在执行 while ((n = gunzip.read(buffer)) >= 0) 这行时报java.util.zip.ZipException: invalid literal/lengths set 错误,求大神看看问题原因是什么?

0
[待解决问题]

public static String uncompress(String str) throws IOException {         if (str == null || str.length() == 0) {             return str;         }         byte[] bytes = Base64.decodeBase64(str);         ByteArrayOutputStream out = new ByteArrayOutputStream();         ByteArrayInputStream in = new ByteArrayInputStream(bytes);         GZIPInputStream gunzip = new GZIPInputStream(in);         byte[] buffer = new byte[256];         int n;         while ((n = gunzip.read(buffer)) >= 0) {             out.write(buffer, 0, n);         }         return out.toString("utf-8");     }

队长给我球。的主页 队长给我球。 | 菜鸟二级 | 园豆:324
提问于:2017-09-12 16:35
< >
分享
所有回答(1)
0

buffer给的空间要够用才行

2012 | 园豆:21230 (高人七级) | 2017-09-22 13:43

每次给256 循环取不可以吗?

支持(0) 反对(0) 队长给我球。 | 园豆:324 (菜鸟二级) | 2017-09-25 10:07

unzip.read(buffer)一次最多读的是多长,是否会超过空间256

支持(0) 反对(0) 2012 | 园豆:21230 (高人七级) | 2017-09-26 08:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册