private int freeSpace(){
  return buffer.capacity() - buffer.limit() + buffer.position();
}

private int freeSpace ( ) { return buffer . capacity ( ) - buffer . limit ( ) + buffer . position ( ) ; }
return the size of free space in a buffer . e . g . given a buffer with pointers 0 < = position < = limit < = capacity , e . g . buffer : | 0 , 0 , 1 , 2 , 3 , 4 , 0 , 0 , 0 , 0 , 0 | | | | | 0 position limit capacity this method returns capacity - limit + position
