public void truncate(int size){
  if (pos > size) {
    byte[] buff=new byte[size];
    System.arraycopy(data,0,buff,0,size);
    this.pos=size;
    data=buff;
  }
}

public void truncate ( int size ) { if ( pos > size ) { byte [ ] buff = new byte [ size ] ; System . arraycopy ( data , 0 , buff , 0 , size ) ; this . pos = size ; data = buff ; } }
shrink the array to this size .
