All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object
|
+----java.io.OutputStream
|
+----java.io.FilterOutputStream
|
+----java.io.PrintStream
In addition, the print stream overrides many of the
InputStream methods so as not to throw an
IOException. Instead, an I/O exception causes an
internal flag to be set, which the application can check by a call
to the checkError method.
Only the lower eight bits of any 16-bit quantity are printed to the stream.
An application can specify at creation time whether a print stream should be flushed every time a newline character is written.
Here are some examples of the use of a print stream:
System.out.println("Hello world!");
System.out.print("x = ");
System.out.println(x);
System.out.println("y = " + y);
Note: This class is provided primarily for use in debugging,
and for compatibility with existing code.
New code should use the PrintWriter class.
"true" to the underlying output
stream if the value of the boolean argument is
true; otherwise, prints the string
"false" to the underlying output stream.
double to
this print stream's underlying output stream.
float to
this print stream's underlying output stream.
int to this
print stream's underlying output stream.
long to this
print stream's underlying output stream.
Object to
this print stream's underlying output stream.
null, the string
"null" is printed to this print stream's underlying
output stream.
"true" followed by a newline
character to this print stream's underlying output stream if the
value of the boolean argument is true;
otherwise prints the string "false" followed by a
newline character to the underlying output stream.
double
followed by a newline to this print stream's underlying output
stream.
float
followed by a newline to this print stream's underlying output
stream.
int followed
by a newline to this print stream's underlying output stream.
long
followed by a newline to this print stream's underlying output
stream.
Object
followed by a newline to this print stream's underlying output
stream.
null, the string
"null" followed by a newline character is printed to
this print stream's underlying output stream.
method PrintStream(out=OutputStream) public
PrintWriter class. Consider replacing
code of the form:
PrintStream p = new PrintStream(out);
PrintWriter p = new PrintWriter(out);
method PrintStream(out=OutputStream, -
autoFlush=boolean) public
PrintWriter class. Consider replacing
code of the form:
PrintStream p = new PrintStream(out, autoFlush);
PrintWriter p = new PrintWriter(out, autoFlush);
autoflush flag is true, then the
underlying output stream's flush method is called any
time a newline character is printed.
true, the stream automatically
flushes its output when a newline character is
printed.
method flush() public
The flush method of PrintStream calls
the flush method of its underlying output stream.
However, if that flush method throws an
IOException, this method catches that exception and
indicates, instead, that the underlying stream has gotten an error
method close() public
The close method of PrintStream calls the
close method of its underlying output stream.
However, if that close method throws an
IOException, this method catches that exception and
indicates, instead, that the underlying stream has gotten an error,
method checkError() returns boolean public
Errors are cumulative; once the print stream has encounted an
error, this method will continue to return true on
all successive calls.
true if the print stream has ever encountered an
error on the output stream or during a format conversion;
false otherwise.
method setError() Inheritable
method write(b=int) public
The write method of PrintStream calls
the write method of its underlying stream. In
addition, if the character is a newline character and autoflush is
turned on, then the print stream's flush method is called.
If any IOException is thrown while writing the byte,
the exception is caught, and instead an internal error flag is
set; the value of the flag can be checked by a call to the
checkError method.
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 or println methods.
method write(buf=byte[], -
off=int, -
len=int) public
len bytes from the specified byte array
starting at offset off to this print stream's
underlying output stream.
method print(b=boolean) public
"true" to the underlying output
stream if the value of the boolean argument is
true; otherwise, prints the string
"false" to the underlying output stream.
boolean to be printed.
method print(c=char) public
char to be printed.
method print(i=int) public
int to this
print stream's underlying output stream. The string representation
is identical to the one returned by the toString
method of class Integer with the argument
i.
int to be printed.
method print(l=long) public
long to this
print stream's underlying output stream. The string representation
is identical to the one returned by the toString
method of class Long with the argument
l.
long to be printed.
method print(f=float) public
float to
this print stream's underlying output stream. The string
representation is identical to the one returned by the
toString method of class Float with the
argument f.
float to be printed.
method print(d=double) public
double to
this print stream's underlying output stream. The string
representation is identical to the one returned by the
toString method of class Double with the
argument d.
double to be printed.
method print(s=char[]) public
method print(s=String) public
null, the string
"null" is printed to this print stream's underlying
output stream. Otherwise, the low eight bits of each of the characters
in the string is printed to the underlying output stream.
method print(obj=Object) public
Object to
this print stream's underlying output stream. The string
representation is identical to the one returned by calling the
Object argument's toString method.
Object to be printed.
method println() public
line.separator, and is not necessarily a single newline
('\n') character.
method println(x=boolean) public
"true" followed by a newline
character to this print stream's underlying output stream if the
value of the boolean argument is true;
otherwise prints the string "false" followed by a
newline character to the underlying output stream.
boolean to be printed.
method println(x=char) public
char to be printed.
method println(x=int) public
int followed
by a newline to this print stream's underlying output stream. The
string representation is identical to the one returned by the
toString method of class Integer with
the argument i.
int to be printed.
method println(x=long) public
long
followed by a newline to this print stream's underlying output
stream. The string representation is identical to the one returned
by the toString method of class Long
with the argument l.
long to be printed.
method println(x=float) public
float
followed by a newline to this print stream's underlying output
stream. The string representation is identical to the one returned
by the toString method of class Integer
with the argument f.
float to be printed.
method println(x=double) public
double
followed by a newline to this print stream's underlying output
stream. The string representation is identical to the one returned
by the toString method of class Double
with the argument d.
double to be printed.
method println(x=char[]) public
method println(x=String) public
null, the string
"null" followed by a newline character is printed to
this print stream's underlying output stream. Otherwise, the low 8
bits of each of the characters in the string, followed by a
newline character, is printed to the underlying output stream.
method println(x=Object) public
Object
followed by a newline to this print stream's underlying output
stream. The string representation is identical to the one returned
by calling the Object argument's
toString method.
Object to be printed.
All Packages Class Hierarchy This Package Previous Next Index