您的位置:首页 > 编程语言 > Java开发

javaI/O之PushbackInputStream

2013-04-01 13:05 288 查看
javaI/O之PushbackInputStream
一、介绍
PushbackInputStream类继承了FilterInputStream类是iputStream类的修饰者。提供可以将数据插入到输入流前端的能力。能够插入的最大字节数与推回缓冲区的大小相关。
二、属性
protected byte[] buf;用于保存插入到输入流前端的数据,读取时先从缓存区读取。
protected int pos;表示缓存区当前读取的位置。
三、构造函数
public PushbackInputStream(InputStream in, int size) ;in为被修饰的输入流。size为推回缓冲区的大小。默认缓冲区大小为1字节。
四、方法
public int read() throws IOException;推回缓冲区中包含数据,则从推回缓冲区读取,否则从输入流中读取。
public int read(byte[] b, int off, int len) throws IOException推回缓冲区中包含数据,则从推回缓冲区读取,然后从输入来看中读取。
public void unread(int b);将数据插入到推回缓冲区中。int类型将被转换为byte类型。
public void unread(byte[] b, int off, int len) throws IOException;将字节数组数据插入到缓冲区中。
public int available() throws IOException;返回推回缓冲区和输入流的可用字节数。
public long skip(long n) throws IOException;先跳过推回缓冲区再跳过输入流。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: