code: public synchronized void trimToSize() throws IOException {
  
          checkFreed();
  
          if (buf.length > count) {
              buf = copyOf(buf, count);
          }
      }
docs: Attempts to reduce this writer's buffer capacity to its current size. <p>
  
  If the buffer is larger than necessary to hold its current sequence of
  characters, then it may be resized to become more space efficient.
  Calling this method may, but is not required to, affect the value
  returned by a subsequent call to the {@link #capacity()} method.