My application gets a large number of large InputStreams, and needs to hand them off to a driver expecting ByteBuffers. Java InputStream to ByteBuffer recommends converting them to byte arrays first; however, that is expensive, and indeed ruins the whole point of using NIO. I'm looking for a way that a driver expecting a ByteBuffer can read from the InputStream as it needs to.
In the case I'm dealing with, consuming the entire InputStream at once and turning it into an array is too expensive and wasteful.