create Byte Buffer - Java java.nio

Java examples for java.nio:ByteBuffer

Description

create Byte Buffer

Demo Code


//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());
    }
}

Related Tutorials