code: public static Writer newWriter(final WritableByteChannel ch,
                                     final CharsetEncoder enc,
                                     final int minBufferCap)
      {
          checkNotNull(ch, "ch");
          return StreamEncoder.forEncoder(ch, enc.reset(), minBufferCap);
      }
docs: Constructs a writer that encodes characters using the given encoder and
  writes the resulting bytes to the given channel.
  
  <p> The resulting stream will contain an internal output buffer of at
  least <tt>minBufferCap</tt> bytes.  The stream's <tt>write</tt> methods
  will, as needed, flush the buffer by writing bytes to the underlying
  channel; if the channel is in non-blocking mode when bytes are to be
  written then an {@link IllegalBlockingModeException} will be thrown.
  The resulting stream will not otherwise be buffered.  Closing the stream
  will in turn cause the channel to be closed.  </p>
  
  @param  ch
  The channel to which bytes will be written
  
  @param  enc
  The charset encoder to be used
  
  @param  minBufferCap
  The minimum capacity of the internal byte buffer,
  or <tt>-1</tt> if an implementation-dependent
  default capacity is to be used
  
  @return  A new writer