< prev index next >
src/java.base/share/classes/java/io/PrintStream.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1996, 2017, 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
--- 1,7 ----
/*
! * 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,54 ****
* 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.
* 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.
--- 43,54 ----
* 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 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,129 ****
private PrintStream(boolean autoFlush, Charset charset, OutputStream out) {
this(out, autoFlush, charset);
}
/**
! * Creates a new print stream. This stream will not flush automatically.
*
* @param out The output stream to which values and objects will be
* printed
*
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)
--- 119,131 ----
private PrintStream(boolean autoFlush, Charset charset, OutputStream out) {
this(out, autoFlush, charset);
}
/**
! * 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,141 ****
public PrintStream(OutputStream out) {
this(out, false);
}
/**
! * Creates a new print stream.
*
* @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
* whenever a byte array is written, one of the
--- 133,145 ----
public PrintStream(OutputStream out) {
this(out, false);
}
/**
! * 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
* whenever a byte array is written, one of the
*** 147,157 ****
public PrintStream(OutputStream out, boolean autoFlush) {
this(autoFlush, requireNonNull(out, "Null output stream"));
}
/**
! * Creates a new print stream.
*
* @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
* whenever a byte array is written, one of the
--- 151,162 ----
public PrintStream(OutputStream out, boolean autoFlush) {
this(autoFlush, requireNonNull(out, "Null output 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
* whenever a byte array is written, one of the
*** 171,181 ****
{
this(requireNonNull(out, "Null output stream"), autoFlush, toCharset(encoding));
}
/**
! * Creates a new print stream, with the specified OutputStream, automatic 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
--- 176,186 ----
{
this(requireNonNull(out, "Null output stream"), autoFlush, toCharset(encoding));
}
/**
! * 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
*** 698,710 ****
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.
*
* @param c The {@code char} to be printed
*/
public void print(char c) {
write(String.valueOf(c));
--- 703,715 ----
write(String.valueOf(b));
}
/**
* Prints a character. The character is translated into one or more 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 c The {@code char} to be printed
*/
public void print(char c) {
write(String.valueOf(c));
*** 766,778 ****
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.
*
* @param s The array of chars to be printed
*
* @throws NullPointerException If {@code s} is {@code null}
*/
--- 771,783 ----
write(String.valueOf(d));
}
/**
* Prints an array of characters. The characters are 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 array of chars to be printed
*
* @throws NullPointerException If {@code s} is {@code null}
*/
*** 781,792 ****
}
/**
* 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
* {@link #write(int)} method.
*
* @param s The {@code String} to be printed
*/
public void print(String s) {
--- 786,798 ----
}
/**
* 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 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 >