模块 java.base
 java.io

类 FilterWriter

java.lang.Object
java.io.Writer
java.io.FilterWriter
所有已实现的接口:
Closeable , Flushable , Appendable , AutoCloseable

public abstract class FilterWriter extends Writer
用于编写过滤字符流的抽象类。抽象类 FilterWriter 本身提供了将所有请求传递给包含的流的默认方法。 FilterWriter 的子类应该覆盖其中一些方法,并且还可以提供额外的方法和字段。
自从:
1.1
  • 字段详细信息

    • out

      protected Writer  out
      底层字符输出流。
  • 构造方法详细信息

    • FilterWriter

      protected FilterWriter(Writer  out)
      创建一个新的过滤编写器。
      参数:
      out - 提供底层流的 Writer 对象。
      抛出:
      NullPointerException - 如果 outnull
  • 方法详情

    • write

      public void write(int c) throws IOException
      写入单个字符。
      重写:
      write 在类 Writer
      参数:
      c - 指定要写入的字符的 int
      抛出:
      IOException - 如果发生 I/O 错误
    • write

      public void write(char[] cbuf, int off, int len) throws IOException
      写入字符数组的一部分。
      指定者:
      write 在类 Writer
      参数:
      cbuf - 要写入的字符缓冲区
      off - 开始读取字符的偏移量
      len - 要写入的字符数
      抛出:
      IndexOutOfBoundsException - 如果 offlen 参数的值导致底层 Writer 的相应方法抛出 IndexOutOfBoundsException
      IOException - 如果发生 I/O 错误
    • write

      public void write(String  str, int off, int len) throws IOException
      写入字符串的一部分。
      重写:
      write 在类 Writer
      参数:
      str - 要写入的字符串
      off - 开始读取字符的偏移量
      len - 要写入的字符数
      抛出:
      IndexOutOfBoundsException - 如果 offlen 参数的值导致底层 Writer 的相应方法抛出 IndexOutOfBoundsException
      IOException - 如果发生 I/O 错误
    • flush

      public void flush() throws IOException
      冲洗流。
      指定者:
      flush 在接口 Flushable
      指定者:
      flush 在类 Writer
      抛出:
      IOException - 如果发生 I/O 错误
    • close

      public void close() throws IOException
      从类复制的描述:Writer
      关闭流,首先冲洗它。流关闭后,进一步的 write() 或 flush() 调用将导致抛出 IOException。关闭之前关闭的流没有任何效果。
      指定者:
      close 在接口 AutoCloseable
      指定者:
      close 在接口 Closeable
      指定者:
      close 在类 Writer
      抛出:
      IOException - 如果发生 I/O 错误