public static String streamToString2(InputStream in) throws IOException {
//定义一个内存输出流
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//将流转换成字符串
GZIPInputStream gis = new GZIPInputStream(in);
int len1 = -1;
byte[] b1 = new byte[1024];
while ((len1 = gis.read(b1)) != -1) {
byteArrayOutputStream.write(b1, 0, len1);
}
byteArrayOutputStream.close();
//转化为数组
// byte[] bytes = byteArrayOutputStream.toByteArray();
return byteArrayOutputStream.toString();
}
GZIP解码方法
最新推荐文章于 2024-07-02 21:53:14 发布