private void ensureAvail(int n){
  if (pos + n >= buf.length) {
    int newSize=Math.max(pos + n,buf.length * 2);
    buf=Arrays.copyOf(buf,newSize);
  }
}

private void ensureAvail ( int n ) { if ( pos + n >= buf . length ) { int newSize = Math . max ( pos + n , buf . length * 2 ) ; buf = Arrays . copyOf ( buf , newSize ) ; } }
make sure there will be enought space in buffer to write n bytes
