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
Print values and objects to a byte stream, using the platform's default character encoding to convert characters into bytes. You can specify that the stream should be flushed every time a newline character is written.

Note: This class is provided primarily for use in debugging, and for compatibility with existing code; new code should use the PrintWriter class.

See Also:
PrintWriter

Constructor Index

 o PrintStream(OutputStream)
Create a new PrintStream. Deprecated.
 o PrintStream(OutputStream, boolean)
Create a new PrintStream. Deprecated.

Method Index

 o checkError()
Flush the stream and check its error state.
 o close()
Close the stream.
 o flush()
Flush the stream, writing any buffered output bytes.
 o print(boolean)
Print a boolean.
 o print(char)
Print a character.
 o print(char[])
Print an array of chracters.
 o print(double)
Print a double.
 o print(float)
Print a float.
 o print(int)
Print an integer.
 o print(long)
Print a long.
 o print(Object)
Print an object.
 o print(String)
Print a String.
 o println()
Finish the line.
 o println(boolean)
Print a boolean, and then finish the line.
 o println(char)
Print a character, and then finish the line.
 o println(char[])
Print an array of characters, and then finish the line.
 o println(double)
Print a double, and then finish the line.
 o println(float)
Print a float, and then finish the line.
 o println(int)
Print an integer, and then finish the line.
 o println(long)
Print a long, and then finish the line.
 o println(Object)
Print an Object, and then finish the line.
 o println(String)
Print a String, and then finish the line.
 o setError()
Indicate that an error has occurred
 o write(byte[], int, int)
Write a portion of a byte array, blocking if necessary.
 o write(int)
Write a byte, blocking if necessary.

Constructors

 o PrintStream
  public PrintStream(OutputStream out)
Note: PrintStream() is deprecated. As of JDK version 1.1, the preferred way to print text is via the PrintWriter class.

Create a new PrintStream.

Parameters:
out - An output stream
See Also:
PrintWriter
 o PrintStream
  public PrintStream(OutputStream out,
                     boolean autoFlush)
Note: PrintStream() is deprecated. As of JDK version 1.1, the preferred way to print text is via the PrintWriter class.

Create a new PrintStream.

Parameters:
out - An output stream
autoFlush - A boolean; if true, the println() methods will flush the output buffer
See Also:
PrintWriter

Methods

 o flush
  public void flush()
Flush the stream, writing any buffered output bytes.

Overrides:
flush in class FilterOutputStream
 o close
  public void close()
Close the stream.

Overrides:
close in class FilterOutputStream
 o checkError
  public boolean checkError()
Flush the stream and check its error state. Errors are cumulative; once the stream encounters an error, this routine will continue to return true on all successive calls.

Returns:
True if the print stream has encountered an error, either on the underlying output stream or during a format conversion.
 o setError
  protected void setError()
Indicate that an error has occurred

 o write
  public void write(int b)
Write a byte, blocking if necessary. Note that the byte is written as given; to write a character via the stream's character-to-byte converter, use the print() or println() methods.

Parameters:
b - The byte to be written
Throws: IOException
If an I/O error occurs
Overrides:
write in class FilterOutputStream
See Also:
print, println
 o write
  public void write(byte buf[],
                    int off,
                    int len)
Write a portion of a byte array, blocking if necessary.

Parameters:
buf - A byte array
off - Offset from which to start reading bytes
len - Number of bytes to write
Throws: IOException
If an I/O error occurs
Overrides:
write in class FilterOutputStream
 o print
  public void print(boolean b)
Print a boolean.

 o print
  public void print(char c)
Print a character.

 o print
  public void print(int i)
Print an integer.

 o print
  public void print(long l)
Print a long.

 o print
  public void print(float f)
Print a float.

 o print
  public void print(double d)
Print a double.

 o print
  public void print(char s[])
Print an array of chracters.

 o print
  public void print(String s)
Print a String.

 o print
  public void print(Object obj)
Print an object.

 o println
  public void println()
Finish the line.

 o println
  public void println(boolean x)
Print a boolean, and then finish the line.

 o println
  public void println(char x)
Print a character, and then finish the line.

 o println
  public void println(int x)
Print an integer, and then finish the line.

 o println
  public void println(long x)
Print a long, and then finish the line.

 o println
  public void println(float x)
Print a float, and then finish the line.

 o println
  public void println(double x)
Print a double, and then finish the line.

 o println
  public void println(char x[])
Print an array of characters, and then finish the line.

 o println
  public void println(String x)
Print a String, and then finish the line.

 o println
  public void println(Object x)
Print an Object, and then finish the line.


All Packages  Class Hierarchy  This Package  Previous  Next  Index