public String decodeByteBuff(ByteBuf buf) throws IOException, DataFormatException {
byte[] temp = new byte[buf.readableBytes()];
ByteBufInputStream bis = new ByteBufInputStream(buf);
bis.read(temp);
bis.close();
Inflater decompresser = new Inflater(true);
decompresser.setInput(temp, 0, temp.length);
StringBuilder sb = new StringBuilder();
byte[] result = new byte[1024];
while (!decompresser.finished()) {
int resultLength = decompresser.inflate(result);
sb.append(new String(result, 0, resultLength, "UTF-8"));
}
decompresser.end();
return sb.toString();
}
上面那段代码在jdk7没任何问题,在jdk1.6.0_4,占用cpu 100%
郁闷,是jdk的bug吗?有高手解答下吗?