code: @Override
      public void close() throws IOException {
          synchronized (lock) {
              if (encoder != null) {
                  drainEncoder();
                  flushBytes(false);
                  out.close();
                  encoder = null;
                  bytes = null;
              }
          }
      }
docs: Closes this writer. This implementation flushes the buffer as well as the
  target stream. The target stream is then closed and the resources for the
  buffer and converter are released.
  
  <p>Only the first invocation of this method has any effect. Subsequent calls
  do nothing.
  
  @throws IOException
  if an error occurs while closing this writer.