summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/io/InputStreamReader.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/io/InputStreamReader.java')
-rw-r--r--libjava/classpath/java/io/InputStreamReader.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/libjava/classpath/java/io/InputStreamReader.java b/libjava/classpath/java/io/InputStreamReader.java
index ef8fd4542db..936a03c95e0 100644
--- a/libjava/classpath/java/io/InputStreamReader.java
+++ b/libjava/classpath/java/io/InputStreamReader.java
@@ -1,5 +1,6 @@
/* InputStreamReader.java -- Reader than transforms bytes to chars
- Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +39,7 @@ exception statement from your version. */
package java.io;
+import gnu.classpath.SystemProperties;
import gnu.java.nio.charset.EncodingHelper;
import java.nio.ByteBuffer;
@@ -145,7 +147,7 @@ public class InputStreamReader extends Reader
this.in = in;
try
{
- encoding = System.getProperty("file.encoding");
+ encoding = SystemProperties.getProperty("file.encoding");
// Don't use NIO if avoidable
if(EncodingHelper.isISOLatin1(encoding))
{
@@ -231,12 +233,20 @@ public class InputStreamReader extends Reader
* charset to decode the bytes in the InputStream into
* characters.
*
- * @since 1.5
+ * @since 1.4
*/
public InputStreamReader(InputStream in, Charset charset) {
+ if (in == null)
+ throw new NullPointerException();
this.in = in;
decoder = charset.newDecoder();
+ try {
+ maxBytesPerChar = charset.newEncoder().maxBytesPerChar();
+ } catch(UnsupportedOperationException _){
+ maxBytesPerChar = 1f;
+ }
+
decoder.onMalformedInput(CodingErrorAction.REPLACE);
decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
decoder.reset();
@@ -247,9 +257,11 @@ public class InputStreamReader extends Reader
* Creates an InputStreamReader that uses the given charset decoder
* to decode the bytes in the InputStream into characters.
*
- * @since 1.5
+ * @since 1.4
*/
public InputStreamReader(InputStream in, CharsetDecoder decoder) {
+ if (in == null)
+ throw new NullPointerException();
this.in = in;
this.decoder = decoder;
OpenPOWER on IntegriCloud