The Closeable, Flushable, Readable, and Appendable interfaces

 

Java SE 5.0引入了4个附加的接口:Closeable、Flushable、Readable和Appendable。
Closeable拥有方法 void close() throws IOException;
Flushable拥有方法 void flush() throws IOException;
Readable拥有方法 public int read(java.nio.CharBuffer cb) throws IOException;
    CharBuffer类拥有按顺序和随机的进行读写访问的方法,它表示一个内存中的缓冲区或者一个内存映像的文件。
Appendable拥有方法
Appendable append(CharSequence csq) throws IOException; //向此 Appendable 添加指定的字符序列。
Appendable append(CharSequence csq, int start, int end) throws IOException; //向此 Appendable 添加指定字符序列的子序列。
Appendable append(char c) throws IOException;   //向此 Appendable 添加指定字符。
    CharSequence接口描述了一个char值序列的基本属性,它是用String、CharBuffer、StringBuilder和StringBuffer来实现的。
InputStream、OutputStream、Reader和Writer都实行了Closeable接口,而OutputStream和Writer还实现了Flushable接口。只有Writer实现了Appendable接口

相关文章:

  • 2022-01-10
  • 2021-11-10
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2021-03-30
  • 2021-12-17
  • 2021-12-06
猜你喜欢
  • 2021-10-25
  • 2021-08-20
  • 2022-12-23
  • 2021-06-13
  • 2021-07-28
  • 2021-08-02
  • 2021-11-09
相关资源
相似解决方案