当前位置: 移动技术网 > IT编程>开发语言>Java > Java中的 FilterInputStream简介_动力节点Java学院整理

Java中的 FilterInputStream简介_动力节点Java学院整理

2019年07月22日  | 移动技术网IT编程  | 我要评论
filterinputstream 介绍 filterinputstream 的作用是用来“封装其它的输入流,并为它们提供额外的功能”。它的常用的子类有bufferedi

filterinputstream 介绍

filterinputstream 的作用是用来“封装其它的输入流,并为它们提供额外的功能”。它的常用的子类有bufferedinputstream和datainputstream。

bufferedinputstream的作用就是为“输入流提供缓冲功能,以及mark()和reset()功能”。

datainputstream 是用来装饰其它输入流,它“允许应用程序以与机器无关方式从底层输入流中读取基本 java 数据类型”。应用程序可以使用dataoutputstream(数据输出流)写入由datainputstream(数据输入流)读取的数据。

filterinputstream 源码(基于jdk1.7.40)

package java.io;
public class filterinputstream extends inputstream {
  protected volatile inputstream in;
  protected filterinputstream(inputstream in) {
    this.in = in;
  }
  public int read() throws ioexception {
    return in.read();
  }
  public int read(byte b[]) throws ioexception {
    return read(b, 0, b.length);
  }
  public int read(byte b[], int off, int len) throws ioexception {
    return in.read(b, off, len);
  }
  public long skip(long n) throws ioexception {
    return in.skip(n);
  }
  public int available() throws ioexception {
    return in.available();
  }
  public void close() throws ioexception {
    in.close();
  }
  public synchronized void mark(int readlimit) {
    in.mark(readlimit);
  }
  public synchronized void reset() throws ioexception {
    in.reset();
  }
  public boolean marksupported() {
    return in.marksupported();
  }
}

以上所述是小编给大家介绍的java中的 filterinputstream简介,希望对大家有所帮助

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网