summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/io/PrintStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/io/PrintStream.java')
-rw-r--r--libjava/classpath/java/io/PrintStream.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/libjava/classpath/java/io/PrintStream.java b/libjava/classpath/java/io/PrintStream.java
index eaab7c3d4b5..caa6035cfcd 100644
--- a/libjava/classpath/java/io/PrintStream.java
+++ b/libjava/classpath/java/io/PrintStream.java
@@ -181,10 +181,15 @@ public class PrintStream extends FilterOutputStream implements Appendable
* @param out The <code>OutputStream</code> to write to.
* @param auto_flush <code>true</code> to flush the stream after every
* line, <code>false</code> otherwise
+ * @exception NullPointerException If out is null.
*/
public PrintStream (OutputStream out, boolean auto_flush)
{
super (out);
+
+ if (out == null)
+ throw new NullPointerException("out is null");
+
String encoding;
try {
encoding = SystemProperties.getProperty("file.encoding");
@@ -213,12 +218,19 @@ public class PrintStream extends FilterOutputStream implements Appendable
* line, <code>false</code> otherwise
* @param encoding The name of the character encoding to use for this
* object.
+ * @exception NullPointerException If out or encoding is null.
*/
public PrintStream (OutputStream out, boolean auto_flush, String encoding)
throws UnsupportedEncodingException
{
super (out);
+ if (out == null)
+ throw new NullPointerException("out is null");
+
+ if (encoding == null)
+ throw new NullPointerException("encoding is null");
+
new String(new byte[]{0}, encoding); // check if encoding is supported
this.encoding = encoding;
this.auto_flush = auto_flush;
OpenPOWER on IntegriCloud