allocate Double Buffer - Java java.nio

Java examples for java.nio:DoubleBuffer

Description

allocate Double Buffer

Demo Code


//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;

public class Main {
    public static void main(String[] argv) throws Exception {
        int numDoubles = 2;
        System.out.println(allocateDoubleBuffer(numDoubles));
    }/* w  w w.  j  a va2  s.  co m*/

    public static DoubleBuffer allocateDoubleBuffer(int numDoubles) {
        ByteBuffer bb;
        int allocationSize = 8 * numDoubles;
        bb = ByteBuffer.allocateDirect(allocationSize);
        bb.order(ByteOrder.LITTLE_ENDIAN);
        return bb.asDoubleBuffer();
    }
}

Related Tutorials