Create a long ByteBuffer in Java
Description
The following code shows how to create a long ByteBuffer.
Example
/*from w w w . j a v a2 s . c o m*/
import java.nio.ByteBuffer;
import java.nio.LongBuffer;
public class Main {
public static void main(String[] argv) throws Exception {
ByteBuffer buf = ByteBuffer.allocate(15);
buf.putLong(123);
buf.rewind();
LongBuffer lbuf = buf.asLongBuffer();
System.out.println(lbuf.get());
}
}
The code above generates the following result.