Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试找到 byteBuffer.putShort 方法的替代方法。我想要 putshort 的相同功能。所以我们有吗?我的 jdk (1.4.2) 不支持字节缓冲区。
问候塞拉加
putShort()没有什么特别的。ByteBuffer 有关于它的 BigEndian 还是 LittleEndian 的信息, - 不确定您的问题是否需要考虑这一点。如果这样做,则需要翻转字节。否则,它只存储到一个支持字节数组,并将短值拆分为字节,如:byte1 = (byte)(myShort >> 8); byte2 = (byte)(myShort >> 0);
putShort()
byte1 = (byte)(myShort >> 8); byte2 = (byte)(myShort >> 0);