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);

Constructor Index

 o PrintStream(OutputStream)
Creates a new PrintStream.
 o PrintStream(OutputStream, boolean)
Creates a new PrintStream, with auto flushing.

Method Index

 o checkError()
Flushes the print stream and returns whether or not there was an error on the output stream.
 o close()
Closes the stream.
 o flush()
Flushes the stream.
 o print(Object)
Prints an object.
 o print(String)
Prints a String.
 o print(char[])
Prints an array of characters.
 o print(char)
Prints an character.
 o print(int)
Prints an integer.
 o print(long)
Prints a long.
 o print(float)
Prints a float.
 o print(double)
Prints a double.
 o print(boolean)
Prints a boolean.
 o println()
Prints a newline.
 o println(Object)
Prints an object followed by a newline.
 o println(String)
Prints a string followed by a newline.
 o println(char[])
Prints an array of characters followed by a newline.
 o println(char)
Prints a character followed by a newline.
 o println(int)
Prints an integer followed by a newline.
 o println(long)
Prints a long followed by a newline.
 o println(float)
Prints a float followed by a newline.
 o println(double)
Prints a double followed by a newline.
 o println(boolean)
Prints a boolean followed by a newline.
 o write(int)
Writes a byte.
 o write(byte[], int, int)
Writes a sub array of bytes.

Constructors

 o PrintStream
  public PrintStream(OutputStream out)
Creates a new PrintStream.
Parameters:
out - the output stream
 o 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

Methods

 o 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
 o 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
 o flush
  public void flush()
Flushes the stream. This will write any buffered output bytes.
Overrides:
flush in class FilterOutputStream
 o close
  public void close()
Closes the stream.
Overrides:
close in class FilterOutputStream
 o 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.
 o print
  public void print(Object obj)
Prints an object.
Parameters:
obj - the object to be printed
 o print
  public synchronized void print(String s)
Prints a String.
Parameters:
s - the String to be printed
 o print
  public synchronized void print(char s[])
Prints an array of characters.
Parameters:
s - the array of chars to be printed
 o print
  public void print(char c)
Prints an character.
Parameters:
c - the character to be printed
 o print
  public void print(int i)
Prints an integer.
Parameters:
i - the integer to be printed
 o print
  public void print(long l)
Prints a long.
Parameters:
l - the long to be printed.
 o print
  public void print(float f)
Prints a float.
Parameters:
f - the float to be printed
 o print
  public void print(double d)
Prints a double.
Parameters:
d - the double to be printed
 o print
  public void print(boolean b)
Prints a boolean.
Parameters:
b - the boolean to be printed
 o println
  public void println()
Prints a newline.
 o println
  public synchronized void println(Object obj)
Prints an object followed by a newline.
Parameters:
obj - the object to be printed
 o println
  public synchronized void println(String s)
Prints a string followed by a newline.
Parameters:
s - the String to be printed
 o 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
 o println
  public synchronized void println(char c)
Prints a character followed by a newline.
Parameters:
c - the character to be printed
 o println
  public synchronized void println(int i)
Prints an integer followed by a newline.
Parameters:
i - the integer to be printed
 o println
  public synchronized void println(long l)
Prints a long followed by a newline.
Parameters:
l - the long to be printed
 o println
  public synchronized void println(float f)
Prints a float followed by a newline.
Parameters:
f - the float to be printed
 o println
  public synchronized void println(double d)
Prints a double followed by a newline.
Parameters:
d - the double to be printed
 o 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