在ByteBuffer中获取和设置非字节Java类型
/**来 自 N o w J a v a . c o m - 时 代 Java**/ import java.nio.ByteBuffer; public class Main { public static void main(String[] args) { // Obtain a ByteBuffer; see also Creating a ByteBuffer ByteBuffer buf = ByteBuffer.allocate(100); // Put values of different types buf.putChar((char) 123); buf.putShort((short) 123); buf.putInt(123); buf.putLong(123L); buf.putFloat(12.3F); /* N o w J a v a . c o m 提 供 */ buf.putDouble(12.3D); // Reset position for reading buf.flip(); // Retrieve the values char c = buf.getChar(); short s = buf.getShort(); int