- java.lang.Object
-
- java.io.Writer
-
- java.io.FilterWriter
-
- All Implemented Interfaces:
-
Closeable,Flushable,Appendable,AutoCloseable
public abstract class FilterWriter extends Writer
用于编写过滤后的字符流的抽象类。 抽象类FilterWriter本身提供了将所有请求传递到包含的流的默认方法。FilterWriter子类应该覆盖这些方法中的一些,并且还可以提供其他方法和字段。- 从以下版本开始:
- 1.1
-
-
构造方法摘要
构造方法 Modifier Constructor 描述 protectedFilterWriter(Writer out)创建一个新的过滤的作者。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidclose()关闭流,先刷新。voidflush()刷新流。voidwrite(char[] cbuf, int off, int len)写入字符数组的一部分。voidwrite(int c)写一个字符voidwrite(String str, int off, int len)写一个字符串的一部分。
-
-
-
字段详细信息
-
out
protected Writer out
底层字符输出流。
-
-
构造方法详细信息
-
FilterWriter
protected FilterWriter(Writer out)
创建一个新的过滤的作者。- 参数
-
out- 提供底层流的Writer对象。 - 异常
-
NullPointerException- 如果out是null
-
-
方法详细信息
-
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写入字符数组的一部分。- Specified by:
-
write在Writer - 参数
-
cbuf- 要写入的字符缓冲区 -
off- 开始读取字符的偏移量 -
len- 要写入的字符数 - 异常
-
IndexOutOfBoundsException- 如果off和len参数的值导致底层Writer的相应方法抛出一个IndexOutOfBoundsException -
IOException- 如果发生I / O错误
-
write
public void write(String str, int off, int len) throws IOException
写一个字符串的一部分。- 重写:
-
write在Writer - 参数
-
str- 要写入的字符串 -
off- 开始读取字符的偏移量 -
len- 要写入的字符数 - 异常
-
IndexOutOfBoundsException- 如果off和len参数的值导致底层Writer的相应方法抛出一个IndexOutOfBoundsException -
IOException- 如果发生I / O错误
-
flush
public void flush() throws IOException刷新流。- Specified by:
-
flush在接口Flushable - Specified by:
-
flush中的Writer - 异常
-
IOException- 如果发生I / O错误
-
close
public void close() throws IOException描述从类别复制:Writer关闭流,先刷新。 一旦流已关闭,进一步的write()或flush()调用将导致抛出IOException。 关闭以前关闭的流无效。- Specified by:
-
close在接口AutoCloseable - Specified by:
-
close在接口Closeable - Specified by:
-
close在Writer - 异常
-
IOException- 如果发生I / O错误
-
-