java.io.PrintStream Maven / Gradle / Ivy
/*
This is not an official specification document, and usage is restricted.
NOTICE
(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
Neither this file nor any files generated from it describe a complete
specification, and they may only be used as described below. For
example, no permission is given for you to incorporate this file, in
whole or in part, in an implementation of a Java specification.
Sun Microsystems Inc. owns the copyright in this file and it is provided
to you for informative, as opposed to normative, use. The file and any
files generated from it may be used to generate other informative
documentation, such as a unified set of documents of API signatures for
a platform that includes technologies expressed as Java APIs. The file
may also be used to produce "compilation stubs," which allow
applications to be compiled and validated for such platforms.
Any work generated from this file, such as unified javadocs or compiled
stub files, must be accompanied by this notice in its entirety.
This work corresponds to the API signatures of JSR 219: Foundation
Profile 1.1. In the event of a discrepency between this work and the
JSR 219 specification, which is available at
http://www.jcp.org/en/jsr/detail?id=219, the latter takes precedence.
*/
package java.io;
/**
* A PrintStream
adds functionality to another output stream,
* namely the ability to print representations of various data values
* conveniently. Two other features are provided as well. Unlike other output
* streams, a PrintStream
never throws an
* IOException
; instead, exceptional situations merely set an
* internal flag that can be tested via the checkError
method.
* Optionally, a PrintStream
can be created so as to flush
* automatically; this means that the flush
method is
* automatically invoked after a byte array is written, one of the
* println
methods is invoked, or a newline character or byte
* ('\n'
) is written.
*
*
All characters printed by a PrintStream
are converted into
* bytes using the platform's default character encoding. The {@link
* PrintWriter}
class should be used in situations that require writing
* characters rather than bytes.
*
* @version 1.21, 00/02/02
* @author Frank Yellin
* @author Mark Reinhold
* @since JDK1.0
*/
public class PrintStream extends FilterOutputStream
{
/**
* Create 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)
*/
public PrintStream(OutputStream out) {
super(out);
}
/**
* Create 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
* println
methods is invoked, or a newline
* character or byte ('\n'
) is written
*
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream, boolean)
*/
public PrintStream(OutputStream out, boolean autoFlush) {
super(out);
}
/**
* Create 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
* println
methods is invoked, or a newline
* character or byte ('\n'
) is written
* @param encoding The name of a supported
*
* character encoding
*
* @exception UnsupportedEncodingException
* If the named encoding is not supported
*/
public PrintStream(OutputStream out, boolean autoFlush, String encoding)
throws UnsupportedEncodingException {
super(out);
}
/**
* Flush the stream. This is done by writing any buffered output bytes to
* the underlying output stream and then flushing that stream.
*
* @see java.io.OutputStream#flush()
*/
public void flush() { }
/**
* Close the stream. This is done by flushing the stream and then closing
* the underlying output stream.
*
* @see java.io.OutputStream#close()
*/
public void close() { }
/**
* Flush the stream and check its error state. The internal error state
* is set to true
when the underlying output stream throws an
* IOException
other than InterruptedIOException
,
* and when the setError
method is invoked. If an operation
* on the underlying output stream throws an
* InterruptedIOException
, then the PrintStream
* converts the exception back into an interrupt by doing:
*
* Thread.currentThread().interrupt();
*
* or the equivalent.
*
* @return True if and only if this stream has encountered an
* IOException
other than
* InterruptedIOException
, or the
* setError
method has been invoked
*/
public boolean checkError() {
return false;
}
/**
* Set the error state of the stream to true
.
*
* @since JDK1.1
*/
protected void setError() { }
/**
* Write the specified byte to this stream. If the byte is a newline and
* automatic flushing is enabled then the flush
method will be
* invoked.
*
* Note that the byte is written as given; to write a character that
* will be translated according to the platform's default character
* encoding, use the print(char)
or println(char)
* methods.
*
* @param b The byte to be written
* @see #print(char)
* @see #println(char)
*/
public void write(int b) { }
/**
* Write len
bytes from the specified byte array starting at
* offset off
to this stream. If automatic flushing is
* enabled then the flush
method will be invoked.
*
*
Note that the bytes will be written as given; to write characters
* that will be translated according to the platform's default character
* encoding, use the print(char)
or println(char)
* methods.
*
* @param buf A byte array
* @param off Offset from which to start taking bytes
* @param len Number of bytes to write
*/
public void write(byte[] buf, int off, int len) { }
/**
* Print a boolean value. The string produced by {@link
* java.lang.String#valueOf(boolean)}
is translated 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 b The boolean
to be printed
*/
public void print(boolean b) { }
/**
* Print 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 char
to be printed
*/
public void print(char c) { }
/**
* Print an integer. The string produced by {@link
* java.lang.String#valueOf(int)}
is translated 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 i The int
to be printed
* @see java.lang.Integer#toString(int)
*/
public void print(int i) { }
/**
* Print a long integer. The string produced by {@link
* java.lang.String#valueOf(long)}
is translated 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 l The long
to be printed
* @see java.lang.Long#toString(long)
*/
public void print(long l) { }
/**
* Print a floating-point number. The string produced by {@link
* java.lang.String#valueOf(float)}
is translated 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 f The float
to be printed
* @see java.lang.Float#toString(float)
*/
public void print(float f) { }
/**
* Print a double-precision floating-point number. The string produced by
* {@link java.lang.String#valueOf(double)}
is translated 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 d The double
to be printed
* @see java.lang.Double#toString(double)
*/
public void print(double d) { }
/**
* Print 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 s
is null
*/
public void print(char[] s) { }
/**
* Print a string. If the argument is null
then the string
* "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 String
to be printed
*/
public void print(String s) { }
/**
* Print an object. The string produced by the {@link
* java.lang.String#valueOf(Object)}
method is translated 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 obj The Object
to be printed
* @see java.lang.Object#toString()
*/
public void print(Object obj) { }
/**
* Terminate the current line by writing the line separator string. The
* line separator string is defined by the system property
* line.separator
, and is not necessarily a single newline
* character ('\n'
).
*/
public void println() { }
/**
* Print a boolean and then terminate the line. This method behaves as
* though it invokes {@link #print(boolean)}
and then
* {@link #println()}
.
*
* @param x The boolean
to be printed
*/
public void println(boolean x) { }
/**
* Print a character and then terminate the line. This method behaves as
* though it invokes {@link #print(char)}
and then
* {@link #println()}
.
*
* @param x The char
to be printed.
*/
public void println(char x) { }
/**
* Print an integer and then terminate the line. This method behaves as
* though it invokes {@link #print(int)}
and then
* {@link #println()}
.
*
* @param x The int
to be printed.
*/
public void println(int x) { }
/**
* Print a long and then terminate the line. This method behaves as
* though it invokes {@link #print(long)}
and then
* {@link #println()}
.
*
* @param x a The long
to be printed.
*/
public void println(long x) { }
/**
* Print a float and then terminate the line. This method behaves as
* though it invokes {@link #print(float)}
and then
* {@link #println()}
.
*
* @param x The float
to be printed.
*/
public void println(float x) { }
/**
* Print a double and then terminate the line. This method behaves as
* though it invokes {@link #print(double)}
and then
* {@link #println()}
.
*
* @param x The double
to be printed.
*/
public void println(double x) { }
/**
* Print an array of characters and then terminate the line. This method
* behaves as though it invokes {@link #print(char[])}
and
* then {@link #println()}
.
*
* @param x an array of chars to print.
*/
public void println(char[] x) { }
/**
* Print a String and then terminate the line. This method behaves as
* though it invokes {@link #print(String)}
and then
* {@link #println()}
.
*
* @param x The String
to be printed.
*/
public void println(String x) { }
/**
* Print an Object and then terminate the line. This method behaves as
* though it invokes {@link #print(Object)}
and then
* {@link #println()}
.
*
* @param x The Object
to be printed.
*/
public void println(Object x) { }
}