EVALUATION
ByteBuffer views of CharBuffer, DoubleBuffer, LongBuffer, etc., objects would
not be particularly useful from an efficiency standpoint. All I/O operations
are ultimately performed only upon direct byte buffers. If you pass a
non-direct byte buffer to a channel read (or write) operation then the bytes
are copied from (to) an internal byte buffer after (before) the actual read
(write) operation is performed. Adding asByteBuffer() methods to the non-byte
buffer classes would not obviate the need for this intermediate copy.
You can easily implement your temporary data store by using views in the other
direction, i.e., by using char, double, etc., views of ByteBuffers. Given a
ByteBuffer you can, e.g., deposit a string into it this way:
ByteBuffer bb = ByteBuffer.allocateDirect(SIZE);
CharBuffer cv = bb.asCharBuffer();
cv.put("String");
There's no need to use encoders or decoders here -- the characters are written
to the byte buffer in big-endian order.
-- ###@###.### 2002/3/22
|