Fri*_*rik 6 java int unsigned short
我在java中编写了一个.obj解析器来模拟iPhone上的3D对象.我想将数据导出为二进制文件,该文件必须尽可能小.我有很多适合无符号短的索引,但它们在java中表示为int.
我想在文件中写入数据之前使用ByteBuffer类进行转换.我想在将它们推入ByteBuffer之前我必须操作字节,但我不知道如何操作.
如果你能帮助我,请提前感谢你.
Mic*_*ers 11
在Java中,unsigned short可以表示为a char.只需将int转换为char并putChar()在ByteBuffer上使用.
char
putChar()
myBuffer.putChar((char) my16BitInt);
归档时间:
15 年,5 月 前
查看次数:
15652 次
最近记录:
9 年,10 月 前