public void setLength ( int length ) { if ( length < 0 || body . length == length ) { return ; } int oldPos = pos ; pos = Math . min ( pos , length ) ; byte [ ] newBody = new byte [ length ] ; System . arraycopy ( body , 0 , newBody , 0 , pos ) ; body = newBody ; if ( oldPos > pos ) { cachedString = null ; } }
Sets the current length of the body . If the current content is longer the excessive data will be truncated .