Example usage for java.nio DoubleBuffer remaining

List of usage examples for java.nio DoubleBuffer remaining

Introduction

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

Prototype

public final int remaining() 

Source Link

Document

Returns the number of remaining elements in this buffer, that is limit - position .

Usage

From source file:Main.java

public static ByteBuffer copyDoubleBufferAsByteBuffer(DoubleBuffer buf) {
    ByteBuffer dest = newByteBuffer(buf.remaining() * SIZEOF_DOUBLE);
    buf.mark();/* w  w w  .ja v a 2s.  c om*/
    dest.asDoubleBuffer().put(buf);
    buf.reset();
    dest.rewind();
    return dest;
}

From source file:ubic.basecode.io.ByteArrayConverter.java

/**
 * @param barray/* w  w w. ja v  a 2  s  . com*/
 * @return double[]
 */
public double[] byteArrayToDoubles(byte[] barray) {
    if (barray == null)
        return null;

    DoubleBuffer buf = ByteBuffer.wrap(barray).asDoubleBuffer();
    double[] array = new double[buf.remaining()];
    buf.get(array);

    return array;

}