I have a ByteBuffer
containing three double values, e.g. {1.0, 2.0, 3.0}
. What I have now is
double[] a = new double[3];
for (int i = 0; i < 3; i++) {
a[i] = byteBuffer.getDouble();
}
which works fine, but I would prefer a one-step solution via
double[] a = byteBuffer.asDoubleBuffer().array();
but this results in a exception:
java.lang.UnsupportedOperationException at java.nio.DoubleBuffer.array(...)
What am I doing wrong?