Example usage for java.nio DoubleBuffer get

List of usage examples for java.nio DoubleBuffer get

Introduction

In this page you can find the example usage for java.nio DoubleBuffer get.

Prototype

public DoubleBuffer get(double[] dest, int off, int len) 

Source Link

Document

Reads doubles from the current position into the specified double array, starting from the specified offset, and increases the position by the number of doubles read.

Usage

From source file:Main.java

public static void main(String[] args) {
    DoubleBuffer bb = DoubleBuffer.allocate(BSIZE);
    bb.put(98765);/*  ww w  .j  a va  2  s . co m*/
    bb.put(98765);
    bb.put(98765);
    bb.put(98765);
    bb.put(98765);

    bb.rewind();

    double[] doubleArray = new double[BSIZE];

    bb.get(doubleArray, 0, 2);

    System.out.println(Arrays.toString(doubleArray));

}

From source file:org.cytobank.fcs_files.events.MemoryEvents.java

public MemoryEvents(File doubleFile) throws IOException, MemoryEventsException {
    this.doubleFile = doubleFile;

    numberOfEvents = (int) doubleFile.length() / BYTES_PER_DOUBLE;

    setupMemoryEventsArray(numberOfEvents);

    try {//from w w w  . j a  v  a  2 s. co m
        // Read in the doubles file
        FileInputStream fileInputStream = new FileInputStream(doubleFile);
        FileChannel fileChannel = fileInputStream.getChannel();
        MappedByteBuffer mappedByteBuffer = fileChannel.map(MapMode.READ_ONLY, 0, doubleFile.length());
        DoubleBuffer doubleBuffer = mappedByteBuffer.asDoubleBuffer();

        doubleBuffer.get(events, 0, numberOfEvents);

        fileChannel.close();
        fileInputStream.close();
    } catch (IOException ioe) {
        destroy();
        throw ioe;
    }

    openedAt = System.currentTimeMillis();
}