java.io.PrintStream
class is a subclass of FilterOutputStream
.
It is implemented by System.out
and System.err
.
It allows very simple printing of both primitive values,
objects, and string literals. It uses the platform's default character encoding to
convert characters into bytes.
This class traps all
IOException
s. However you can test the error status with checkError()
. This returns true
if an error has occurred,
false
otherwise.
public boolean checkError()
The main use of the class is the exceptionally overloaded
print()
and println()
methods. They differ in that println()
adds an end-of-line character to whatever it prints while print()
does not.
public void print(boolean b)
public void print(int i)
public void print(long l)
public void print(float f)
public void print(double d)
public void print(char s[])
public void print(String s)
public void print(Object obj)
public void println()
public void println(boolean x)
public void println(char x)
public void println(int x)
public void println(long x)
public void println(float x)
public void println(double x)
public void println(char x[])
public void println(String x)
public void println(Object x)
PrintStream
is primarily intended for debugging.
Otherwise it's unofficially deprecated in Java 1.1.
You should use the PrintWriter
class instead.