20230625 java.io.PrintWriter

介绍

  • java.io.PrintWriter
  • public class PrintWriter extends Writer
  • 对应的字节流是 PrintStream
  • 主要作用是文本输出
  • 可以作为装饰器包装 WriterOutputStream ,会装饰成 BufferedWriter

API

构造器

  • PrintWriter (Writer out)
  • PrintWriter(Writer out, boolean autoFlush)
  • PrintWriter(OutputStream out)
  • PrintWriter(OutputStream out, boolean autoFlush)
  • PrintWriter(OutputStream out, boolean autoFlush, Charset charset)
  • PrintWriter(String fileName) throws FileNotFoundException
  • PrintWriter(String fileName, String csn) throws FileNotFoundException, UnsupportedEncodingException
  • PrintWriter(String fileName, Charset charset) throws IOException
  • PrintWriter(File file) throws FileNotFoundException
  • PrintWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException
  • PrintWriter(File file, Charset charset) throws IOException
    • csn 表示 charsetName ,字符集名称
    • autoFlush 表示 自动冲刷模式(默认禁用),只要 println 被调用,缓冲区中的所有字符被 flush
      • autoFlush 只影响 println 方法,不影响其他方法

public

  • checkError
    • 如果产生格式化或输出错误,则返回 true
    • 一旦这个流碰到了错误,它就受到了污染,并且所有对 checkError 的调用都将返回 true
  • print
    • 通过打印从 toString 产生的字符串来打印一个对象
  • println
    • 打印一个字符串,后面紧跟一个行终止符。如果这个流处于自动冲刷模式,那么就会冲刷这个流
  • printf
    • 按照格式字符串指定的方式打印给定的值
  • format
    • 使用指定的格式字符串和参数将格式化字符串写入此 Writer 。如果启用自动刷新,则调用此方法将刷新输出缓冲区
posted @   流星<。)#)))≦  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-08-23 20190823 尚硅谷MySQL核心技术
2017-08-23 面试的角度诠释Java工程师
2016-08-23 JavaScript 全局
2016-08-23 HTML字符实体
点击右上角即可分享
微信分享提示