Rumah > Soal Jawab > teks badan
如题,想将接收到的消息输出到终端,直接调用toString()方法,只能看到一部分,如下
HeapBuffer[pos=0 lim=37 cap=1024: 09 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00...]
高洛峰2017-04-17 11:41:23
byte[] b = new byte [ioBuffer.limit()];
ioBuffer.get(b);
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < b.length; i++) {
buffer.append((char) b [i]);
}
return buffer.toString();
GOOD LUCK!