J
Jesper Sahner
Hi!
Using the Buffer-classes in Java NIO you can read blocks/arrays of
data by using allocate() or wrap() on an existing array. Further you
can use a view-buffer to read integers, doubles etc. into a ByteBuffer
as if it was integers, doubles etc. you were reading.
So far so good.
Let's say that you wan't to read a sequence of e.g. integers a, b, c,
d and e. An array x[5] can be read directly using an IntBuffer or
using ByteBuffer.asIntBuffer().
Is it possible to read a, b, c, d and e the same way, meaning in one
read?
If NOT you'll have to:
1) read a, b, c, d and e one by one
or:
2) read into an array x[5] and then put a=x[0],...,e=x[4]
Neither of these methods are elegant or (even worse) fast ways to read
data.
Any suggestions for improvements?
Regards,
Jesper
Using the Buffer-classes in Java NIO you can read blocks/arrays of
data by using allocate() or wrap() on an existing array. Further you
can use a view-buffer to read integers, doubles etc. into a ByteBuffer
as if it was integers, doubles etc. you were reading.
So far so good.
Let's say that you wan't to read a sequence of e.g. integers a, b, c,
d and e. An array x[5] can be read directly using an IntBuffer or
using ByteBuffer.asIntBuffer().
Is it possible to read a, b, c, d and e the same way, meaning in one
read?
If NOT you'll have to:
1) read a, b, c, d and e one by one
or:
2) read into an array x[5] and then put a=x[0],...,e=x[4]
Neither of these methods are elegant or (even worse) fast ways to read
data.
Any suggestions for improvements?
Regards,
Jesper