java::io::PrintStream Class Reference

Inheritance diagram for java::io::PrintStream:

Inheritance graph
java::lang::Objectjava::lang::Interfacejava::io::OutputStream
[legend]
Collaboration diagram for java::io::PrintStream:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::io::OutputStreamjava::lang::Comparable
[legend]

List of all members.


Detailed Description

A PrintStream adds functionality to another output stream, namely the ability to print representations of various data values conveniently.

Two other features are provided as well. Unlike other output streams, a PrintStream never throws an IOException; instead, exceptional situations merely set an internal flag that can be tested via the checkError method. Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('
'
) is written.

All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. The PrintWriter class should be used in situations that require writing characters rather than bytes.

Version:
1.24, 01/12/03
Author:
Frank Yellin

Mark Reinhold

Since:
JDK1.0

Public Member Functions

 PrintStream (const Ref< OutputStream > &out=0, jboolean autoFlush=false, const String &enc=nilCString)
 Create a new print stream.
virtual void write (jint b)
 Writes the specified byte to this file output stream.
virtual void write (const Array< jbyte > &b, jint off=0, jint len=-1)
 Writes len bytes from the specified byte array starting at offset off to this file output stream.
virtual void flush ()
 Flushes this output stream and forces any buffered output bytes to be written out to the stream.
virtual void close ()
 Closes this file output stream and releases any system resources associated with this stream.
virtual jboolean checkError ()
 Flush the stream and check its error state.
virtual void print (const String &s)
 Print a string.
virtual void println (const String &x=nilString)
 Print a String and then terminate the line.

Constructor & Destructor Documentation

java::io::PrintStream::PrintStream ( const Ref< OutputStream > &  out = 0,
jboolean  autoFlush = false,
const String enc = nilCString 
)

Create a new print stream.

Parameters:
out The output stream to which values and objects will be printed
autoFlush A boolean; if true, the output buffer will be flushed whenever a byte array is written, one of the println methods is invoked, or a newline character or byte ('
'
) is written
encoding The name of a supported character encoding
Exceptions:
UnsupportedEncodingException If the named encoding is not supported


Member Function Documentation

virtual void java::io::PrintStream::write ( jint  b  )  [virtual]

Writes the specified byte to this file output stream.

Parameters:
b the byte to be written.
Exceptions:
IOException if an I/O error occurs.
Since:
JDK1.0

Implements java::io::OutputStream.

virtual void java::io::PrintStream::write ( const Array< jbyte > &  b,
jint  off = 0,
jint  len = -1 
) [virtual]

Writes len bytes from the specified byte array starting at offset off to this file output stream.

Parameters:
b the data.
off the start offset in the data.
len the number of bytes to write.
Exceptions:
IOException if an I/O error occurs.
Since:
JDK1.0

Implements java::io::OutputStream.

virtual void java::io::PrintStream::flush (  )  [virtual]

Flushes this output stream and forces any buffered output bytes to be written out to the stream.

The flush method of PrintStream calls the flush method of its underlying output stream.

Exceptions:
IOException if an I/O error occurs.

Reimplemented from java::io::OutputStream.

virtual void java::io::PrintStream::close (  )  [virtual]

Closes this file output stream and releases any system resources associated with this stream.

Exceptions:
IOException if an I/O error occurs.
Since:
JDK1.0

Reimplemented from java::io::OutputStream.

virtual jboolean java::io::PrintStream::checkError (  )  [virtual]

Flush the stream and check its error state.

The internal error state is set to true when the underlying output stream throws an IOException other than InterruptedIOException, and when the setError method is invoked. If an operation on the underlying output stream throws an InterruptedIOException, then the PrintStream converts the exception back into an interrupt by doing:

     Thread.currentThread().interrupt();
 
or the equivalent.

Returns:
True if and only if this stream has encountered an IOException other than InterruptedIOException, or the setError method has been invoked

virtual void java::io::PrintStream::print ( const String s  )  [virtual]

Print a string.

If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) method.

Parameters:
s The String to be printed

virtual void java::io::PrintStream::println ( const String x = nilString  )  [virtual]

Print a String and then terminate the line.

This method behaves as though it invokes print(String) and then println().

Parameters:
x The String to be printed.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:32 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3