Java 1.4 NIO view buffers and arrays

Issue 1. The ByteBuffer class defines methods that can create views of a given ByteBuffer such as:

CharBuffer asCharBuffer()

DoubleBuffer asDoubleBuffer()

LongBuffer as LongBuffer()

... etc.

Why is there no corresponding method in the view buffer classes to create a ByteBuffer view? The NIO class Channel only has methods for IO using ByteBuffer so the only way I can see to write a DoubleBuffer is to 'copy' it into a ByteBuffer. Ideally I would like to create a ByteBuffer view of a DoubleBuffer and/or be able to write a DoubleBuffer directly via a Channel method.

Issue 2. Each of the NIO Buffer classes has a static method to wrap an array of a specific type with a Buffer of the same type such as:

in class ByteBuffer:

ByteBuffer wrap(byte[])

in class DoubleBuffer:

DoubleBuffer wrap(double[])

... etc.

Why is there no corresponding method to create a view array of a specific type from a Buffer of the same type? Ideally I would like to create a 'view' array backed by a Buffer of the same type

[1093 byte] By [llschumacher] at [2007-9-26 2:48:55]
# 1

hmm. I think I ran into your bug post too. At least it seemed to be the exact same wording. I am just writing in here to revive your post and post

http://forum.java.sun.com/thread.jsp?forum=4&thread=240316

where I actually added more info. Maybe someone will responsd to that post. I think your idea also would solve the problem we talk about in that post. I don't care really how they solve it. Person in that post wwas thinking the same way I was where the position in the very backing buffer would update no matter which view was written too. I may repost this bug but wanted to collect these posts first.

dean

deanhiller2000 at 2007-6-29 10:34:33 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...