JavaTM Platform
Standard Ed. 6

java.io
类 FilterWriter

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

public abstract class FilterWriter
extends Writer

用于写入已过滤的字符流的抽象类。抽象类 FilterWriter 自身提供了一些将所有请求传递给所包含的流的默认方法。FilterWriter 的子类应重写这些方法中的一些方法,并且还可以提供一些额外的方法和字段。

从以下版本开始:
JDK1.1

字段摘要
protected  Writer out
          底层字符输出流。
 
从类 java.io.Writer 继承的字段
lock
 
构造方法摘要
protected FilterWriter(Writer out)
          创建一个新的 filtered writer。
 
方法摘要
 void close()
          关闭此流,但要先刷新它。
 void flush()
          刷新该流的缓冲。
 void write(char[] cbuf, int off, int len)
          将字符写入数组的某一部分。
 void write(int c)
          写入单个字符。
 void write(String str, int off, int len)
          写入一部分字符串。
 
从类 java.io.Writer 继承的方法
append, append, append, write, write
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

out

protected Writer out
底层字符输出流。

构造方法详细信息

FilterWriter

protected FilterWriter(Writer out)
创建一个新的 filtered writer。

参数:
out - 提供底层流的 Writer 对象。
抛出:
NullPointerException - 如果 outnull
方法详细信息

write

public void write(int c)
           throws IOException
写入单个字符。

覆盖:
Writer 中的 write
参数:
c - 指定要写入字符的 int。
抛出:
IOException - 如果发生 I/O 错误

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
将字符写入数组的某一部分。

指定者:
Writer 中的 write
参数:
cbuf - 要写入的字符缓冲区
off - 偏移量,从该处开始读取字符
len - 要写入字符的数量
抛出:
IOException - 如果发生 I/O 错误

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
写入一部分字符串。

覆盖:
Writer 中的 write
参数:
str - 要写入的字符串
off - 偏移量,从该处开始读取字符
len - 要写入字符的数量
抛出:
IOException - 如果发生 I/O 错误

flush

public void flush()
           throws IOException
刷新该流的缓冲。

指定者:
接口 Flushable 中的 flush
指定者:
Writer 中的 flush
抛出:
IOException - 如果发生 I/O 错误

close

public void close()
           throws IOException
从类 Writer 复制的描述
关闭此流,但要先刷新它。在关闭该流之后,再调用 write() 或 flush() 将导致抛出 IOException。关闭以前关闭的流无效。

指定者:
接口 Closeable 中的 close
指定者:
Writer 中的 close
抛出:
IOException - 如果发生 I/O 错误

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策