public byte [ ] getBuffer ( ) { if ( buf == null ) return null ; if ( offset == 0 && length == buf . length ) return buf ; else { byte [ ] retval = new byte [ length ] ; System . arraycopy ( buf , offset , retval , 0 , length ) ; return retval ; } }
Returns a copy of the buffer if offset and length are used otherwise a reference .