/*     */ public OutputStreamWriter(OutputStream paramOutputStream, String paramString)
     /*     */ throws UnsupportedEncodingException
       /*     */ {
   /*  97 */ super(paramOutputStream);
   /*  98 */ if (paramString == null) /*  99 */ throw new NullPointerException("charsetName");
   /* 100 */ this.se = StreamEncoder.forOutputStreamWriter(paramOutputStream, this, paramString);
   /*     */ }
 /**
  * Create an OutputStreamWriter that uses the default character encoding.
  *
  * @param out An OutputStream
  */
 public OutputStreamWriter(OutputStream out) {
   super(out);
   try {
     se = StreamEncoder.forOutputStreamWriter(out, this, (String) null);
   } catch (UnsupportedEncodingException e) {
     throw new Error(e);
   }
 }
 /*     */ public OutputStreamWriter(
     OutputStream paramOutputStream, CharsetEncoder paramCharsetEncoder)
       /*     */ {
   /* 149 */ super(paramOutputStream);
   /* 150 */ if (paramCharsetEncoder == null)
     /* 151 */ throw new NullPointerException("charset encoder");
   /* 152 */ this.se =
       StreamEncoder.forOutputStreamWriter(paramOutputStream, this, paramCharsetEncoder);
   /*     */ }
 /*     */ public OutputStreamWriter(OutputStream paramOutputStream) /*     */ {
   /* 109 */ super(paramOutputStream);
   /*     */ try {
     /* 111 */ this.se =
         StreamEncoder.forOutputStreamWriter(paramOutputStream, this, (String) null);
     /*     */ } catch (UnsupportedEncodingException localUnsupportedEncodingException) {
     /* 113 */ throw new Error(localUnsupportedEncodingException);
     /*     */ }
   /*     */ }
 /*     */ public OutputStreamWriter(OutputStream paramOutputStream, Charset paramCharset)
       /*     */ {
   /* 130 */ super(paramOutputStream);
   /* 131 */ if (paramCharset == null) /* 132 */ throw new NullPointerException("charset");
   /* 133 */ this.se = StreamEncoder.forOutputStreamWriter(paramOutputStream, this, paramCharset);
   /*     */ }
 /**
  * Create an OutputStreamWriter that uses the given charset.
  *
  * @param out An OutputStream
  * @param cs A charset
  * @since 1.4
  * @spec JSR-51
  */
 public OutputStreamWriter(OutputStream out, Charset cs) {
   super(out);
   if (cs == null) throw new NullPointerException("charset");
   se = StreamEncoder.forOutputStreamWriter(out, this, cs);
 }
 /**
  * Create an OutputStreamWriter that uses the named charset.
  *
  * @param out An OutputStream
  * @param charsetName The name of a supported {@link java.nio.charset.Charset
  *     </code>charset<code>}
  * @exception UnsupportedEncodingException If the named encoding is not supported
  */
 public OutputStreamWriter(OutputStream out, String charsetName)
     throws UnsupportedEncodingException {
   super(out);
   if (charsetName == null) throw new NullPointerException("charsetName");
   se = StreamEncoder.forOutputStreamWriter(out, this, charsetName);
 }
 /**
  * Flush the stream.
  *
  * @exception IOException If an I/O error occurs
  */
 public void flush() throws IOException {
   se.flush();
 }
 /**
  * Close the stream.
  *
  * @exception IOException If an I/O error occurs
  */
 public void close() throws IOException {
   se.close();
 }
 /**
  * Write a portion of an array of characters.
  *
  * @param cbuf Buffer of characters
  * @param off Offset from which to start writing characters
  * @param len Number of characters to write
  * @exception IOException If an I/O error occurs
  */
 public void write(char cbuf[], int off, int len) throws IOException {
   se.write(cbuf, off, len);
 }
 /**
  * Write a portion of a string.
  *
  * @param str A String
  * @param off Offset from which to start writing characters
  * @param len Number of characters to write
  * @exception IOException If an I/O error occurs
  */
 public void write(String str, int off, int len) throws IOException {
   se.write(str, off, len);
 }
 /**
  * Write a single character.
  *
  * @exception IOException If an I/O error occurs
  */
 public void write(int c) throws IOException {
   se.write(c);
 }
 /**
  * Flush the output buffer to the underlying byte stream, without flushing the byte stream itself.
  * This method is non-private only so that it may be invoked by PrintStream.
  */
 void flushBuffer() throws IOException {
   se.flushBuffer();
 }
 /**
  * Return the name of the character encoding being used by this stream.
  *
  * <p>If the encoding has an historical name then that name is returned; otherwise the encoding's
  * canonical name is returned.
  *
  * <p>If this instance was created with the {@link #OutputStreamWriter(OutputStream, String)}
  * constructor then the returned name, being unique for the encoding, may differ from the name
  * passed to the constructor. This method may return <tt>null</tt> if the stream has been closed.
  *
  * @return The historical name of this encoding, or possibly <code>null</code> if the stream has
  *     been closed
  * @see java.nio.charset.Charset
  * @revised 1.4
  * @spec JSR-51
  */
 public String getEncoding() {
   return se.getEncoding();
 }
 /**
  * Create an OutputStreamWriter that uses the given charset encoder.
  *
  * @param out An OutputStream
  * @param enc A charset encoder
  * @since 1.4
  * @spec JSR-51
  */
 public OutputStreamWriter(OutputStream out, CharsetEncoder enc) {
   super(out);
   if (enc == null) throw new NullPointerException("charset encoder");
   se = StreamEncoder.forOutputStreamWriter(out, this, enc);
 }
Beispiel #16
0
 /**
  * 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 {@code minBufferCap}
  * bytes. The stream's {@code write} 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.
  *
  * @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 {@code -1} if an
  *     implementation-dependent default capacity is to be used
  * @return A new writer
  */
 public static Writer newWriter(WritableByteChannel ch, CharsetEncoder enc, int minBufferCap) {
   Objects.requireNonNull(ch, "ch");
   return StreamEncoder.forEncoder(ch, enc.reset(), minBufferCap);
 }