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

##

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

##

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

##

PrintWriter

     public PrintWriter(Writer out)

  Create a new PrintWriter, without automatic line flushing.

  Parameters:
    out - A character-output stream

PrintWriter

     public PrintWriter(Writer out,
                        boolean autoFlush)

  Create a new PrintWriter.

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

PrintWriter

     public PrintWriter(OutputStream out)

  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

PrintWriter

     public PrintWriter(OutputStream out,
                        boolean autoFlush)

  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

##

flush

     public void flush()

  Flush the stream.

  Overrides:
    flush in class Writer

close

     public void close()

  Close the stream.

  Overrides:
    close in class Writer

checkError

     public boolean checkError()

  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.

setError

     protected void setError()

  Indicate that an error has occurred.

write

     public void write(int c)

  Write a single character.

  Overrides:
    write in class Writer

write

     public void write(char buf[],
                       int off,
                       int len)

  Write a portion of an array of characters.

  Overrides:
    write in class Writer

write

     public void write(char buf[])

  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

write

     public void write(String s,
                       int off,
                       int len)

  Write a portion of a string.

  Overrides:
    write in class Writer

write

     public void write(String s)

  Write a string. This method cannot be inherited from the Writer class because it must suppress I/O exceptions.

  Overrides:
    write in class Writer

print

     public void print(boolean b)

  Print a boolean.

print

     public void print(char c)

  Print a character.

print

     public void print(int i)

  Print an integer.

print

     public void print(long l)

  Print a long.

print

     public void print(float f)

  Print a float.

print

     public void print(double d)

  Print a double.

print

     public void print(char s[])

  Print an array of chracters.

print

     public void print(String s)

  Print a String.

print

     public void print(Object obj)

  Print an object.

println

     public void println()

  Finish the line.

println

     public void println(boolean x)

  Print a boolean, and then finish the line.

println

     public void println(char x)

  Print a character, and then finish the line.

println

     public void println(int x)

  Print an integer, and then finish the line.

println

     public void println(long x)

  Print a long, and then finish the line.

println

     public void println(float x)

  Print a float, and then finish the line.

println

     public void println(double x)

  Print a double, and then finish the line.

println

     public void println(char x[])

  Print an array of characters, and then finish the line.

println

     public void println(String x)

  Print a String, and then finish the line.

println

     public void println(Object x)

  Print an Object, and then finish the line.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.