Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.io
Class PrintStream  view PrintStream download PrintStream.java

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended byjava.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.

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


Field Summary
private  boolean auto_flush
          This is true if auto-flush is enabled, false otherwise
private  java.lang.String encoding
          Encoding name
private  boolean error_occurred
          This boolean indicates whether or not an error has ever occurred on this stream.
private static char[] line_separator
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
PrintStream(OutputStream out)
          This method intializes a new PrintStream object to write to the specified output sink.
PrintStream(OutputStream out, boolean auto_flush)
          This method intializes a new PrintStream object to write to the specified output sink.
PrintStream(OutputStream out, boolean auto_flush, java.lang.String encoding)
          This method intializes a new PrintStream object to write to the specified output sink.
 
Method Summary
 boolean checkError()
          This method checks to see if an error has occurred on this stream.
 void close()
          This method closes this stream and all underlying streams.
 void flush()
          This method flushes any buffered bytes to the underlying stream and then flushes that stream as well.
 void print(boolean bool)
          This methods prints a boolean value to the stream.
 void print(char ch)
          This method prints a char to the stream.
 void print(char[] charArray)
          This method prints an array of characters to the stream.
private  void print(char[] chars, int pos, int len, boolean println)
           
 void print(double dnum)
          This method prints a double to the stream.
 void print(float fnum)
          This method prints a float to the stream.
 void print(int inum)
          This method prints an integer to the stream.
 void print(long lnum)
          This method prints a long to the stream.
 void print(java.lang.Object obj)
          This method prints an Object to the stream.
 void print(java.lang.String str)
          This method prints a String to the stream.
private  void print(java.lang.String str, boolean println)
           
 void println()
          This method prints a line separator sequence to the stream.
 void println(boolean bool)
          This methods prints a boolean value to the stream.
 void println(char ch)
          This method prints a char to the stream.
 void println(char[] charArray)
          This method prints an array of characters to the stream.
 void println(double dnum)
          This method prints a double to the stream.
 void println(float fnum)
          This method prints a float to the stream.
 void println(int inum)
          This method prints an integer to the stream.
 void println(long lnum)
          This method prints a long to the stream.
 void println(java.lang.Object obj)
          This method prints an Object to the stream.
 void println(java.lang.String str)
          This method prints a String to the stream.
protected  void setError()
          This method can be called by subclasses to indicate that an error has occurred and should be reported by checkError.
 void write(byte[] buffer, int offset, int len)
          This method writes len bytes from the specified array starting at index offset into the array.
 void write(int oneByte)
          This method writes a byte of data to the stream.
private  void writeChars(char[] buf, int offset, int count)
           
private  void writeChars(java.lang.String str, int offset, int count)
           
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

line_separator

private static final char[] line_separator

encoding

private java.lang.String encoding
Encoding name


error_occurred

private boolean error_occurred
This boolean indicates whether or not an error has ever occurred on this stream.


auto_flush

private boolean auto_flush
This is true if auto-flush is enabled, false otherwise

Constructor Detail

PrintStream

public PrintStream(OutputStream out)
This method intializes a new PrintStream object to write to the specified output sink.


PrintStream

public PrintStream(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 print or println call, when the write methods with array arguments are called, or when a single new-line character is written.


PrintStream

public PrintStream(OutputStream out,
                   boolean auto_flush,
                   java.lang.String encoding)
            throws UnsupportedEncodingException
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 print or println call, when the write methods with array arguments are called, or when a single new-line character is written.

Method Detail

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.


setError

protected void setError()
This method can be called by subclasses to indicate that an error has occurred and should be reported by checkError.


close

public void close()
This method closes this stream and all underlying streams.

Overrides:
close in class FilterOutputStream

flush

public void flush()
This method flushes any buffered bytes to the underlying stream and then flushes that stream as well.

Overrides:
flush in class FilterOutputStream

print

private void print(java.lang.String str,
                   boolean println)

print

private void print(char[] chars,
                   int pos,
                   int len,
                   boolean println)

writeChars

private void writeChars(char[] buf,
                        int offset,
                        int count)
                 throws IOException

writeChars

private void writeChars(java.lang.String str,
                        int offset,
                        int count)
                 throws IOException

print

public void print(boolean bool)
This methods prints a boolean value to the stream. true values are printed as "true" and false values are printed as "false".


print

public void print(int inum)
This method prints an integer to the stream. The value printed is determined using the String.valueOf() method.


print

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


print

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


print

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


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.


print

public void print(java.lang.String str)
This method prints a String to the stream. The actual value printed depends on the system default encoding.


print

public void print(char ch)
This method prints a char to the stream. The actual value printed is determined by the character encoding in use.


print

public void print(char[] charArray)
This method prints an array of characters to the stream. The actual value printed depends on the system default encoding.


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 bool)
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.


println

public void println(int inum)
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.


println

public void println(long lnum)
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.


println

public void println(float fnum)
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.


println

public void println(double dnum)
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.


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.


println

public void println(java.lang.String str)
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.


println

public void println(char ch)
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.


println

public void println(char[] charArray)
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.


write

public void write(int oneByte)
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.

Overrides:
write in class FilterOutputStream

write

public void write(byte[] buffer,
                  int offset,
                  int len)
This method writes len bytes from the specified array starting at index offset into the array.

Overrides:
write in class FilterOutputStream