public void compactBuffer(){
  if (offset != buffer.length) {
    byte[] newBuffer=new byte[offset];
    System.arraycopy(buffer,0,newBuffer,0,offset);
    buffer=newBuffer;
  }
}

public void compactBuffer ( ) { if ( offset != buffer . length ) { byte [ ] newBuffer = new byte [ offset ] ; System . arraycopy ( buffer , 0 , newBuffer , 0 , offset ) ; buffer = newBuffer ; } }
reallocates the buffer in order to make it exactly the size of data it contains
