javaI/O之PushbackInputStream

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;先跳过推回缓冲区再跳过输入流。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值