Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.io

Class PrintStream

java.lang.Object
|
+--java.io.OutputStream
   |
   +--java.io.FilterOutputStream
      |
      +--java.io.PrintStream


public class PrintStream

extends FilterOutputStream

This class prints Java primitive values and object to a stream as text. None of the methods in this class throw an exception. However, errors can be detected by calling the checkError() method. Additionally, this stream can be designated as "autoflush" when created so that any writes are automatically flushed to the underlying output sink when the current line is terminated.

Note that this class is deprecated. It exists for backward compatibility only. New code should be written to use PrintWriter instead.

This class converts char's into byte's using the system default encoding.

Author:

Constructor Summary

PrintStream(java.io.OutputStream out)

This method intializes a new PrintStream object to write to the specified output sink.
PrintStream(java.io.OutputStream out, boolean auto_flush)

This method intializes a new PrintStream object to write to the specified output sink.

Method Summary

booleancheckError()

This method checks to see if an error has occurred on this stream.
synchronized voidclose()

This method closes this stream and all underlying streams.
voidflush()

This method flushes any buffered bytes to the underlying stream and then flushes that stream as well.
voidprint(boolean b)

This methods prints a boolean value to the stream.
voidprint(char c)

This method prints a char to the stream.
voidprint(int i)

This method prints an integer to the stream.
voidprint(long l)

This method prints a long to the stream.
voidprint(float f)

This method prints a float to the stream.
voidprint(double d)

This method prints a double to the stream.
voidprint(char[] s)

This method prints an array of characters to the stream.
voidprint(java.lang.String s)

This method prints a String to the stream.
voidprint(java.lang.Object obj)

This method prints an Object to the stream.
voidprintln()

This method prints a line separator sequence to the stream.
voidprintln(boolean b)

This methods prints a boolean value to the stream.
voidprintln(char c)

This method prints a char to the stream.
voidprintln(int i)

This method prints an integer to the stream.
voidprintln(long l)

This method prints a long to the stream.
voidprintln(float f)

This method prints a float to the stream.
voidprintln(double d)

This method prints a double to the stream.
voidprintln(char[] s)

This method prints an array of characters to the stream.
voidprintln(java.lang.String s)

This method prints a String to the stream.
voidprintln(java.lang.Object obj)

This method prints an Object to the stream.
voidsetError()

This method can be called by subclasses to indicate that an error has occurred and should be reported by checkError.
synchronized voidwrite(int b)

This method writes a byte of data to the stream.
synchronized voidwrite(byte[] buf, int offset, int len)

This method writes len bytes from the specified array starting at index offset into the array.

Constructor Details

PrintStream

public PrintStream(java.io.OutputStream out)

This method intializes a new PrintStream object to write to the specified output sink. Note that this class is deprecated in favor of PrintWriter.

Parameters:


PrintStream

public PrintStream(java.io.OutputStream out, boolean auto_flush)

This method intializes a new PrintStream object to write to the specified output sink. This constructor also allows "auto-flush" functionality to be specified where the stream will be flushed after every line is terminated or newline character is written.

Note that this class is deprecated in favor of PrintWriter.

Parameters:


Method Details

checkError

public boolean checkError()

This method checks to see if an error has occurred on this stream. Note that once an error has occurred, this method will continue to report true forever for this stream. Before checking for an error condition, this method flushes the stream.

Returns:


close

public synchronized void close()

This method closes this stream and all underlying streams.


flush

public void flush()

This method flushes any buffered bytes to the underlying stream and then flushes that stream as well.


print

public void print(boolean b)

This methods prints a boolean value to the stream. true values are printed as "true" and false values are printed as "false".

Parameters:


print

public void print(char c)

This method prints a char to the stream. The actual value printed is determined by the character encoding in use.

Parameters:


print

public void print(char[] s)

This method prints an array of characters to the stream. The actual value printed depends on the system default encoding.

Parameters:


print

public void print(double d)

This method prints a double to the stream. The value printed is determined using the String.valueOf() method.

Parameters:


print

public void print(float f)

This method prints a float to the stream. The value printed is determined using the String.valueOf() method.

Parameters:


print

public void print(int i)

This method prints an integer to the stream. The value printed is determined using the String.valueOf() method.

Parameters:


print

public void print(java.lang.Object obj)

This method prints an Object to the stream. The actual value printed is determined by calling the String.valueOf() method.

Parameters:


print

public void print(java.lang.String s)

This method prints a String to the stream. The actual value printed depends on the system default encoding.

Parameters:


print

public void print(long l)

This method prints a long to the stream. The value printed is determined using the String.valueOf() method.

Parameters:


println

public void println()

This method prints a line separator sequence to the stream. The value printed is determined by the system property line.separator and is not necessarily the Unix '\n' newline character.


println

public void println(boolean b)

This methods prints a boolean value to the stream. true values are printed as "true" and false values are printed as "false".

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(char c)

This method prints a char to the stream. The actual value printed is determined by the character encoding in use.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(char[] s)

This method prints an array of characters to the stream. The actual value printed depends on the system default encoding.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(double d)

This method prints a double to the stream. The value printed is determined using the String.valueOf() method.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(float f)

This method prints a float to the stream. The value printed is determined using the String.valueOf() method.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(int i)

This method prints an integer to the stream. The value printed is determined using the String.valueOf() method.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(java.lang.Object obj)

This method prints an Object to the stream. The actual value printed is determined by calling the String.valueOf() method.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(java.lang.String s)

This method prints a String to the stream. The actual value printed depends on the system default encoding.

This method prints a line termination sequence after printing the value.

Parameters:


println

public void println(long l)

This method prints a long to the stream. The value printed is determined using the String.valueOf() method.

This method prints a line termination sequence after printing the value.

Parameters:


setError

protected void setError()

This method can be called by subclasses to indicate that an error has occurred and should be reported by checkError.


write

public synchronized void write(byte[] buf, int offset, int len)

This method writes len bytes from the specified array starting at index offset into the array.

Parameters:


write

public synchronized void write(int b)

This method writes a byte of data to the stream. If auto-flush is enabled, printing a newline character will cause the stream to be flushed after the character is written.

Parameters: