← 返回首页
PrintWriter (Java SE 26 & JDK 26)
JavaScript is disabled on your browser.
Contents  
  1. Description
  2. Field Summary
  3. Constructor Summary
  4. Method Summary
    1. Methods declared in class Writer
    2. Methods declared in class Object
  5. Field Details
    1. out
  6. Constructor Details
    1. PrintWriter(Writer)
    2. PrintWriter(Writer, boolean)
    3. PrintWriter(OutputStream)
    4. PrintWriter(OutputStream, boolean)
    5. PrintWriter(OutputStream, boolean, Charset)
    6. PrintWriter(String)
    7. PrintWriter(String, String)
    8. PrintWriter(String, Charset)
    9. PrintWriter(File)
    10. PrintWriter(File, String)
    11. PrintWriter(File, Charset)
  7. Method Details
    1. flush()
    2. close()
    3. checkError()
    4. setError()
    5. clearError()
    6. write(int)
    7. write(char[], int, int)
    8. write(char[])
    9. write(String, int, int)
    10. write(String)
    11. print(boolean)
    12. print(char)
    13. print(int)
    14. print(long)
    15. print(float)
    16. print(double)
    17. print(char[])
    18. print(String)
    19. print(Object)
    20. println()
    21. println(boolean)
    22. println(char)
    23. println(int)
    24. println(long)
    25. println(float)
    26. println(double)
    27. println(char[])
    28. println(String)
    29. println(Object)
    30. printf(String, Object...)
    31. printf(Locale, String, Object...)
    32. format(String, Object...)
    33. format(Locale, String, Object...)
    34. append(CharSequence)
    35. append(CharSequence, int, int)
    36. append(char)
Hide sidebar  Show sidebar

Class PrintWriter

java.lang.Object
java.io.Writer
java.io.PrintWriter
All Implemented Interfaces: Closeable, Flushable, Appendable, AutoCloseable
public class PrintWriter extends Writer
Prints 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, printf, or format methods is invoked, rather than whenever a newline character happens to be output. These methods use the platform's own notion of line separator rather than the newline character.

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

This class always replaces malformed and unmappable character sequences with the charset's default replacement string. The CharsetEncoder class should be used when more control over the encoding process is required.

Since: 1.1

Scripting on this page tracks web page traffic, but does not change the content in any way.