【发布时间】:2019-07-30 12:12:01
【问题描述】:
在解压GZIP压缩后的数组之前,想知道原始数组的长度,以便申请合适的缓冲数组。如以下代码中的“1024”。谢谢!
byte[] buffer = new byte[1024];
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
try (ByteArrayInputStream bin = new ByteArrayInputStream(localByteBuf);
GZIPInputStream gis = new GZIPInputStream(bin)) {
int len;
while ((len = gis.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}
【问题讨论】: