public void read ( ByteBuffer buffer ) { Persistables . persistable ( streamableNoBuffers ( ) ) . read ( buffer ) ; final int n = getNumDataBuffers ( ) ; int lengthsPosition = buffer . position ( ) ; buffer . position ( buffer . position ( ) + 2 * n ) ; // skip positions for ( int i = 0 ; i < n ; i ++ ) { final int size = buffer . getShort ( lengthsPosition ) & 0xFFFF ; // big-endian lengthsPosition += 2 ; final ByteBuffer b1 = Persistables . slice ( buffer , size ) ; setDataBuffer ( i , b1 ) ; } }
Note that you cannot use this method to read a buffer wrapping the array returned from toByteArray as the internal representation is different!