鸿蒙OS开发文档 鸿蒙OS Readable

2024-02-25 开发教程 鸿蒙OS开发文档 匿名 0

Readable

public interface Readable

Readable 是字符的来源。 来自 Readable 的字符可通过 CharBuffer 提供给 read 方法的调用者。

方法总结

修饰符和类型方法描述
intread(CharBuffer cb)尝试将字符读入指定的字符缓冲区。

方法详情

read

int read(CharBuffer cb) throws IOException

尝试将字符读入指定的字符缓冲区。 缓冲区按原样用作字符的存储库:所做的唯一更改是 put 操作的结果。 不执行缓冲区的翻转或倒带。

参数:

参数名称参数描述
cb将字符读入的缓冲区

返回:

添加到缓冲区的 char 值的数量,如果此字符源位于其末尾,则为 -1

Throws:

Throw名称Throw描述
IOException如果发生 I/O 错误
NullPointerException如果 cb 为空
ReadOnlyBufferException如果 cb 是只读缓冲区