Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.nio.DoubleBuffer;

public class Main {
    /**
     * Creates a double array from the provided {@link DoubleBuffer}.
     * 
     * @param buffer {@link DoubleBuffer} the data source.
     * @return double array containing the data of the buffer.
     */
    public static double[] getDoubleArrayFromBuffer(DoubleBuffer buffer) {
        double[] array = null;
        if (buffer.hasArray()) {
            array = buffer.array();
        } else {
            buffer.rewind();
            array = new double[buffer.capacity()];
            buffer.get(array);
        }
        return array;
    }
}