Class java.io.PrintStream
All Packages Class Hierarchy This Package Previous Next Index
Class java.io.PrintStream
java.lang.Object
|
+----java.io.OutputStream
|
+----java.io.FilterOutputStream
|
+----java.io.PrintStream
- public class PrintStream
- extends FilterOutputStream
This class implements an output stream that has
additional methods for printing. You can specify
that the stream should be flushed every time a
newline character is written.The top byte of 16 bit characters is discarded.
Example:
System.out.println("Hello world!");
System.out.print("x = ");
System.out.println(x);
System.out.println("y = " + y);
PrintStream(OutputStream) - Creates a new PrintStream.
PrintStream(OutputStream, boolean) - Creates a new PrintStream, with auto flushing.
checkError() - Flushes the print stream and returns whether or not there was
an error on the output stream.
close() - Closes the stream.
flush() - Flushes the stream.
print(boolean) - Prints a boolean.
print(char) - Prints an character.
print(char[]) - Prints an array of characters.
print(double) - Prints a double.
print(float) - Prints a float.
print(int) - Prints an integer.
print(long) - Prints a long.
print(Object) - Prints an object.
print(String) - Prints a String.
println() - Prints a newline.
println(boolean) - Prints a boolean followed by a newline.
println(char) - Prints a character followed by a newline.
println(char[]) - Prints an array of characters followed by a newline.
println(double) - Prints a double followed by a newline.
println(float) - Prints a float followed by a newline.
println(int) - Prints an integer followed by a newline.
println(long) - Prints a long followed by a newline.
println(Object) - Prints an object followed by a newline.
println(String) - Prints a string followed by a newline.
write(byte[], int, int) - Writes a sub array of bytes.
write(int) - Writes a byte.
PrintStream
public PrintStream(OutputStream out)
- Creates a new PrintStream.
- Parameters:
- out - the output stream
PrintStream
public PrintStream(OutputStream out,
boolean autoflush)
- Creates a new PrintStream, with auto flushing.
- Parameters:
- out - the output stream
- autoflush - if true the stream automatically flushes its output when a newline character is printed
write
public void write(int b)
- Writes a byte. This method will block until the byte is actually
written.
- Parameters:
- b - the byte
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- write in class FilterOutputStream
write
public void write(byte b[],
int off,
int len)
- Writes a sub array of bytes.
- Parameters:
- b - the data to be written
- off - the start offset in the data
- len - the number of bytes that are written
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- write in class FilterOutputStream
flush
public void flush()
- Flushes the stream. This will write any buffered
output bytes.
- Overrides:
- flush in class FilterOutputStream
close
public void close()
- Closes the stream.
- Overrides:
- close in class FilterOutputStream
checkError
public boolean checkError()
- Flushes the print stream and returns whether or not there was
an error on the output stream. Errors are cumulative; once the
print stream encounters an error this routine will continue to
return true on all successive calls.
- Returns:
- true if the print stream has ever encountered an error
on the output stream.
print
public void print(Object obj)
- Prints an object.
- Parameters:
- obj - the object to be printed
print
public synchronized void print(String s)
- Prints a String.
- Parameters:
- s - the String to be printed
print
public synchronized void print(char s[])
- Prints an array of characters.
- Parameters:
- s - the array of chars to be printed
print
public void print(char c)
- Prints an character.
- Parameters:
- c - the character to be printed
print
public void print(int i)
- Prints an integer.
- Parameters:
- i - the integer to be printed
print
public void print(long l)
- Prints a long.
- Parameters:
- l - the long to be printed.
print
public void print(float f)
- Prints a float.
- Parameters:
- f - the float to be printed
print
public void print(double d)
- Prints a double.
- Parameters:
- d - the double to be printed
print
public void print(boolean b)
- Prints a boolean.
- Parameters:
- b - the boolean to be printed
println
public void println()
- Prints a newline.
println
public synchronized void println(Object obj)
- Prints an object followed by a newline.
- Parameters:
- obj - the object to be printed
println
public synchronized void println(String s)
- Prints a string followed by a newline.
- Parameters:
- s - the String to be printed
println
public synchronized void println(char s[])
- Prints an array of characters followed by a newline.
- Parameters:
- s - the array of characters to be printed
println
public synchronized void println(char c)
- Prints a character followed by a newline.
- Parameters:
- c - the character to be printed
println
public synchronized void println(int i)
- Prints an integer followed by a newline.
- Parameters:
- i - the integer to be printed
println
public synchronized void println(long l)
- Prints a long followed by a newline.
- Parameters:
- l - the long to be printed
println
public synchronized void println(float f)
- Prints a float followed by a newline.
- Parameters:
- f - the float to be printed
println
public synchronized void println(double d)
- Prints a double followed by a newline.
- Parameters:
- d - the double to be printed
println
public synchronized void println(boolean b)
- Prints a boolean followed by a newline.
- Parameters:
- b - the boolean to be printed
All Packages Class Hierarchy This Package Previous Next Index