/**
* 对字节流进行GBK解码
*
* @param byteBuffer
* @return
*/
public static String decode(ByteBuffer byteBuffer) {
Charset charset = Charset.forName("ISO-8859-1");
CharsetDecoder decoder = charset.newDecoder();
try {
CharBuffer charBuffer = decoder.decode(byteBuffer);
return new String(charBuffer.toString().getBytes("ISO8859_1"),
"GBK").trim();
} catch (Exception e) {
return null;
}
}
|