Java examples for java.nio:ByteBuffer
create Byte Buffer
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { /**/*from ww w .j a va 2s .co m*/ * * @param size * @return */ public static ByteBuffer createByteBuffer(int size) { return prepareBuffer(ByteBuffer.allocate(size)); } /** * * @param buffer * @return */ private static ByteBuffer prepareBuffer(ByteBuffer buffer) { return buffer.order(ByteOrder.nativeOrder()); } }