Java examples for java.nio:ByteBuffer
allocate Byte Buffer
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static void main(String[] argv) throws Exception { int numBytes = 2; System.out.println(allocateByteBuffer(numBytes)); }//from w ww . j a v a 2 s. com public static ByteBuffer allocateByteBuffer(int numBytes) { ByteBuffer bb; int allocationSize = numBytes; bb = ByteBuffer.allocateDirect(allocationSize); bb.order(ByteOrder.LITTLE_ENDIAN); return bb; } }