< prev index next >

src/java.base/share/classes/java/io/PrintStream.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -43,12 +43,12 @@
  * automatically invoked after a byte array is written, one of the
  * {@code println} methods is invoked, or a newline character or byte
  * ({@code '\n'}) is written.
  *
  * <p> All characters printed by a {@code PrintStream} are converted into
- * bytes using the given encoding or charset, or platform's default character
- * encoding if not specified.
+ * bytes using the given encoding or charset, or the platform's default
+ * character encoding if not specified.
  * The {@link PrintWriter} class should be used in situations that require
  *  writing characters rather than bytes.
  *
  * <p> This class always replaces malformed and unmappable character sequences with
  * the charset's default replacement string.

@@ -119,11 +119,13 @@
     private PrintStream(boolean autoFlush, Charset charset, OutputStream out) {
         this(out, autoFlush, charset);
     }
 
     /**
-     * Creates a new print stream.  This stream will not flush automatically.
+     * Creates a new print stream, without automatic line flushing, with the
+     * specified OutputStream. Characters written to the stream are converted
+     * to bytes using the platform's default character encoding.
      *
      * @param  out        The output stream to which values and objects will be
      *                    printed
      *
      * @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)

@@ -131,15 +133,17 @@
     public PrintStream(OutputStream out) {
         this(out, false);
     }
 
     /**
-     * Creates a new print stream.
+     * Creates a new print stream, with the specified OutputStream and line
+     * flushing. Characters written to the stream are converted to bytes using
+     * the platform's default character encoding.
      *
      * @param  out        The output stream to which values and objects will be
      *                    printed
-     * @param  autoFlush  A boolean; if true, the output buffer will be flushed
+     * @param  autoFlush  Whether the output buffer will be flushed
      *                    whenever a byte array is written, one of the
      *                    {@code println} methods is invoked, or a newline
      *                    character or byte ({@code '\n'}) is written
      *
      * @see java.io.PrintWriter#PrintWriter(java.io.OutputStream, boolean)

@@ -147,15 +151,16 @@
     public PrintStream(OutputStream out, boolean autoFlush) {
         this(autoFlush, requireNonNull(out, "Null output stream"));
     }
 
     /**
-     * Creates a new print stream.
+     * Creates a new print stream, with the specified OutputStream, line
+     * flushing, and character encoding.
      *
      * @param  out        The output stream to which values and objects will be
      *                    printed
-     * @param  autoFlush  A boolean; if true, the output buffer will be flushed
+     * @param  autoFlush  Whether the output buffer will be flushed
      *                    whenever a byte array is written, one of the
      *                    {@code println} methods is invoked, or a newline
      *                    character or byte ({@code '\n'}) is written
      * @param  encoding   The name of a supported
      *                    <a href="../lang/package-summary.html#charenc">

@@ -171,18 +176,18 @@
     {
         this(requireNonNull(out, "Null output stream"), autoFlush, toCharset(encoding));
     }
 
     /**
-     * Creates a new print stream, with the specified OutputStream, automatic line
+     * Creates a new print stream, with the specified OutputStream, line
      * flushing and charset.  This convenience constructor creates the necessary
      * intermediate {@link java.io.OutputStreamWriter OutputStreamWriter},
      * which will encode characters using the provided charset.
      *
      * @param  out        The output stream to which values and objects will be
      *                    printed
-     * @param  autoFlush  A boolean; if true, the output buffer will be flushed
+     * @param  autoFlush  Whether the output buffer will be flushed
      *                    whenever a byte array is written, one of the
      *                    {@code println} methods is invoked, or a newline
      *                    character or byte ({@code '\n'}) is written
      * @param  charset    A {@linkplain java.nio.charset.Charset charset}
      *

@@ -698,13 +703,13 @@
         write(String.valueOf(b));
     }
 
     /**
      * Prints a character.  The character is translated into one or more bytes
-     * according to the platform's default character encoding, and these bytes
-     * are written in exactly the manner of the
-     * {@link #write(int)} method.
+     * according to the character encoding given to the constructor, or the
+     * platform's default character encoding if none specified. These bytes
+     * are written in exactly the manner of the {@link #write(int)} method.
      *
      * @param      c   The {@code char} to be printed
      */
     public void print(char c) {
         write(String.valueOf(c));

@@ -766,13 +771,13 @@
         write(String.valueOf(d));
     }
 
     /**
      * Prints an array of characters.  The characters are converted into bytes
-     * according to the platform's default character encoding, and these bytes
-     * are written in exactly the manner of the
-     * {@link #write(int)} method.
+     * according to the character encoding given to the constructor, or the
+     * platform's default character encoding if none specified. These bytes
+     * are written in exactly the manner of the {@link #write(int)} method.
      *
      * @param      s   The array of chars to be printed
      *
      * @throws  NullPointerException  If {@code s} is {@code null}
      */

@@ -781,12 +786,13 @@
     }
 
     /**
      * Prints a string.  If the argument is {@code null} then the string
      * {@code "null"} is printed.  Otherwise, the string's characters are
-     * converted into bytes according to the platform's default character
-     * encoding, and these bytes are written in exactly the manner of the
+     * converted into bytes according to the character encoding given to the
+     * constructor, or the platform's default character encoding if none
+     * specified. These bytes are written in exactly the manner of the
      * {@link #write(int)} method.
      *
      * @param      s   The {@code String} to be printed
      */
     public void print(String s) {
< prev index next >