I have ByteBufferone containing three double values, for example. {1.0, 2.0, 3.0}. Now I have
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 over
double[] a = byteBuffer.asDoubleBuffer().array();
but this leads to an exception:
java.lang.UnsupportedOperationException at java.nio.DoubleBuffer.array(...)
What am I doing wrong?
source
share