--- old/src/java.base/share/classes/java/nio/channels/Channels.java 2017-12-11 11:59:45.154073465 -0800 +++ new/src/java.base/share/classes/java/nio/channels/Channels.java 2017-12-11 11:59:44.914061448 -0800 @@ -527,7 +527,7 @@ * behaves in exactly the same way as the expression * *
 {@code
-     *     Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
+     *     Channels.newReader(ch, Charset.forName(csName))
      * } 
* * @param ch @@ -550,6 +550,38 @@ } /** + * Constructs a reader that decodes bytes from the given channel according + * to the given charset. + * + *

An invocation of this method of the form + * + *

 {@code
+     *     Channels.newReader(ch, charset)
+     * } 
+ * + * behaves in exactly the same way as the expression + * + *
 {@code
+     *     Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
+     * } 
+ * + *

The reader's default action for malformed-input and unmappable-character + * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report} + * them. When more control over the error handling is required, the constructor + * that takes a {@linkplain java.nio.charset.CharsetDecoder} should be used. + * + * @param ch The channel from which bytes will be read + * + * @param charset The charset to be used + * + * @return A new reader + */ + public static Reader newReader(ReadableByteChannel ch, Charset charset) { + Objects.requireNonNull(charset, "charset"); + return newReader(ch, charset.newDecoder(), -1); + } + + /** * Constructs a writer that encodes characters using the given encoder and * writes the resulting bytes to the given channel. * @@ -595,7 +627,7 @@ * behaves in exactly the same way as the expression * *

 {@code
-     *     Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
+     *     Channels.newWriter(ch, Charset.forName(csName))
      * } 
* * @param ch @@ -616,4 +648,38 @@ Objects.requireNonNull(csName, "csName"); return newWriter(ch, Charset.forName(csName).newEncoder(), -1); } + + /** + * Constructs a writer that encodes characters according to the given + * charset and writes the resulting bytes to the given channel. + * + *

An invocation of this method of the form + * + *

 {@code
+     *     Channels.newWriter(ch, charset)
+     * } 
+ * + * behaves in exactly the same way as the expression + * + *
 {@code
+     *     Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
+     * } 
+ * + *

The writer's default action for malformed-input and unmappable-character + * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report} + * them. When more control over the error handling is required, the constructor + * that takes a {@linkplain java.nio.charset.CharsetEncoder} should be used. + * + * @param ch + * The channel to which bytes will be written + * + * @param charset + * The charset to be used + * + * @return A new writer + */ + public static Writer newWriter(WritableByteChannel ch, Charset charset) { + Objects.requireNonNull(charset, "charset"); + return newWriter(ch, charset.newEncoder(), -1); + } }