D
Derek Waldron
Hi,
I have a very large double[] that I want to send across a channel in
java.nio. Is there a better way to do this than the following?
double[] myarray = new double[very large];
ByteBuffer bb = ByteBuffer.allocate(myarray.length*8);
DoubleBuffer db = bb.asDoubleBuffer;
db.put(myarray);
channel.write(bb);
It seems to me that there should be a more direct way by using
DoubleBuffer directly, for example:
DoubleBuffer db = DoubleBuffer.wrap(myarray);
but write only accepts ByteBuffer and so channel.write(db) won't work.
Ideally, I would like to avoid the first piece of code because it
requires copying the entire array.
Any suggestions?
Thanks!
Derek
I have a very large double[] that I want to send across a channel in
java.nio. Is there a better way to do this than the following?
double[] myarray = new double[very large];
ByteBuffer bb = ByteBuffer.allocate(myarray.length*8);
DoubleBuffer db = bb.asDoubleBuffer;
db.put(myarray);
channel.write(bb);
It seems to me that there should be a more direct way by using
DoubleBuffer directly, for example:
DoubleBuffer db = DoubleBuffer.wrap(myarray);
but write only accepts ByteBuffer and so channel.write(db) won't work.
Ideally, I would like to avoid the first piece of code because it
requires copying the entire array.
Any suggestions?
Thanks!
Derek