The object to which I need to write a ByteBuffer is typed as an instance of interface DataOutput, rather than as an instance of class DataOutputStream (which implements DataOutput). I need to assume ByteBuffer.hasArray() can return false, so I don't have access to any underlying array.
Neither DataOutput nor DataOutputStream provide a write method that accepts a ByteBuffer. However, writing a ByteBuffer to a DataOutputStream can be done with a WritableByteChannel, obtained by passing the OutputStream to a utility method of the Channels class. But DataOutput is not type compatible with OutputStream, and no analogous utility method exists.
Does the SDK provide any efficient routines for doing this? I would rather not have to create an intermediate byte array and loop through the ByteBuffer with bulk get operations (effectively replicating the code of WritableByteChannel implementations).