All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.io.PrintWriter

java.lang.Object
   |
   +----java.io.Writer
           |
           +----java.io.PrintWriter

public class PrintWriter
extends Writer
Print formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.

Unlike the PrintStream class, if automatic flushing is enabled it will be done only when one of the println() methods is invoked, rather than whenever a newline character happens to be output. The println() methods use the platform's own notion of line separator rather than the newline character.

Methods in this class never throw I/O exceptions. The client may inquire as to whether any errors have occurred by invoking checkError().


Constructor Index

 o PrintWriter(OutputStream)
Create a new PrintWriter, without automatic line flushing, from an existing OutputStream.
 o PrintWriter(OutputStream, boolean)
Create a new PrintWriter from an existing OutputStream.
 o PrintWriter(Writer)
Create a new PrintWriter, without automatic line flushing.
 o PrintWriter(Writer, boolean)
Create a new PrintWriter.

Method Index

 o checkError()
Flush the stream and check its error state.
 o close()
Close the stream.
 o flush()
Flush the stream.
 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(char[])
Write an array of characters.
 o write(char[], int, int)
Write a portion of an array of characters.
 o write(int)
Write a single character.
 o write(String)
Write a string.
 o write(String, int, int)
Write a portion of a string.

Constructors

 o PrintWriter
    method PrintWriter(out=Writer) public 
Create a new PrintWriter, without automatic line flushing.

Parameters:
out - A character-output stream
 o PrintWriter
    method PrintWriter(out=Writer, -
                       autoFlush=boolean) public 
Create a new PrintWriter.

Parameters:
out - A character-output stream
autoFlush - A boolean; if true, the println() methods will flush the output buffer
 o PrintWriter
    method PrintWriter(out=OutputStream) public 
Create a new PrintWriter, without automatic line flushing, from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.

Parameters:
out - An output stream
See Also:
OutputStreamWriter
 o PrintWriter
    method PrintWriter(out=OutputStream, -
                       autoFlush=boolean) public 
Create a new PrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.

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

Methods

 o flush
    method flush()  public     
Flush the stream.

Overrides:
flush in class Writer
 o close
    method close()  public     
Close the stream.

Overrides:
close in class Writer
 o checkError
    method checkError() returns boolean public     
Flush the stream and check its error state. Errors are cumulative; once the stream encounters an error, this routine will 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
    method setError()  Inheritable     
Indicate that an error has occurred.

 o write
    method write(c=int)  public     
Write a single character.

Overrides:
write in class Writer
 o write
    method write(buf=char[], -
                 off=int, -
                 len=int)  public     
Write a portion of an array of characters.

Overrides:
write in class Writer
 o write
    method write(buf=char[])  public     
Write an array of characters. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

Overrides:
write in class Writer
 o write
    method write(s=String, -
                 off=int, -
                 len=int)  public     
Write a portion of a string.

Overrides:
write in class Writer
 o write
    method write(s=String)  public     
Write a string. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

Overrides:
write in class Writer
 o print
    method print(b=boolean)  public     
Print a boolean.

 o print
    method print(c=char)  public     
Print a character.

 o print
    method print(i=int)  public     
Print an integer.

 o print
    method print(l=long)  public     
Print a long.

 o print
    method print(f=float)  public     
Print a float.

 o print
    method print(d=double)  public     
Print a double.

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

 o print
    method print(s=String)  public     
Print a String.

 o print
    method print(obj=Object)  public     
Print an object.

 o println
    method println()  public     
Finish the line.

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

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

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

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

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

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

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

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

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


All Packages  Class Hierarchy  This Package  Previous  Next  Index