public List < ByteBuffer > readFullyScatterGather ( long position , int length ) throws IOException { byte [ ] buf = new byte [ length ] ; readFully ( position , buf , 0 , length ) ; LinkedList < ByteBuffer > results = new LinkedList < ByteBuffer > ( ) ; results . add ( ByteBuffer . wrap ( buf , 0 , length ) ) ; return results ; }
This can be optimized to avoid buffer copies . It allows the underlying system to return a list of ByteBuffers that contain the data . A FileSystem implementation can override this method to make it avoid redundant memory copies .