The Closeable, Flushable, Readable, and Appendable interfaces

本文介绍了Java SE 5.0中新增的四个接口:Closeable、Flushable、Readable和Appendable。详细解释了这些接口提供的功能及其实现类,包括它们在InputStream、OutputStream、Reader和Writer中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 


 

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接口

  • 大小: 55 KB
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值