解释包含不同数据类型的Bytebuffer

时间:2013-12-06 14:27:29

标签: java

我有一个包含字符和字母的Bytebuffer。如果我将其转换为CharBuffer,数字值将显示为奇怪的符号。我怎样才能确保它们被解释为数字?

//p is a Bytebuffer

CharBuffer cb = p.asCharBuffer();
String result = "";
String byteResult ="";

while (p.hasRemaining()) {           
     char c = cb.get();
     result = result.concat("" + c);

     byte b = p.get();
     byteResult =byteResult.concat(""+b);*/         
}

System.out.println("char Inhalt: " + result);
System.out.println("byte Inhalt: " + byteResult);

提前致谢!

0 个答案:

没有答案