aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/io/InputStreamReader.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/io/InputStreamReader.java')
-rw-r--r--libjava/java/io/InputStreamReader.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/libjava/java/io/InputStreamReader.java b/libjava/java/io/InputStreamReader.java
index e55f135..91568c5 100644
--- a/libjava/java/io/InputStreamReader.java
+++ b/libjava/java/io/InputStreamReader.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package java.io;
import gnu.gcj.convert.*;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
/**
* This class reads characters from a byte input stream. The characters
@@ -131,6 +133,25 @@ public class InputStreamReader extends Reader
this(in, BytesToUnicode.getDecoder(encoding_name));
}
+ /**
+ * Creates an InputStreamReader that uses a decoder of the given
+ * charset to decode the bytes in the InputStream into
+ * characters.
+ */
+ public InputStreamReader(InputStream in, Charset charset)
+ {
+ this(in, new BytesToCharsetAdaptor(charset));
+ }
+
+ /**
+ * Creates an InputStreamReader that uses the given charset decoder
+ * to decode the bytes in the InputStream into characters.
+ */
+ public InputStreamReader(InputStream in, CharsetDecoder decoder)
+ {
+ this(in, new BytesToCharsetAdaptor(decoder));
+ }
+
private InputStreamReader(InputStream in, BytesToUnicode decoder)
{
// FIXME: someone could pass in a BufferedInputStream whose buffer