FilterInputStream
简述
继承自InputStream,实现接口Closeable, AutoCloseable。
成员:InputStream in使用volatile修饰
由于该方法全部会使用类java.io.InputStream,所以推荐先看关于InputStream的api或我写的关于InputStream的介绍
函数
构造函数:FilterInputStream(InputStream in),使用protected修饰
protected FilterInputStream(InputStream in) {
this.in = in;
}
函数:
int read()
在输入流读取指针所指下一个字节,并将指针移动到该字节上。字节值以int形式返回。如果没有可用的字节,因为已经到达了流的末端,则返回值-1。此方法会阻塞数据流,如果检测到阻塞会返回IOException。
public int read() throws IOException {
return in.read();
}
int read(byte b[])
调用函数read(byte b[], int off, int len)
public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
}
int read(byte b[], int off, int len)
从输入流读取数据到字节数组。试图读取尽可能多的len字节,但是可以读取较小的数字。实际上读取的字节数作为一个整数返回。这个方法会阻塞直到输入数据可用,检测到文件的结束,或者抛出异常。
本方法通过read()以bety的形式读取数据。并存入b[]中。off为b起始字符,len为读取长度
public int read(byte b[], int off, int len) throws IOException {
return in.read(b, off, len);
}
long skip(long n)
利用read(byte b[], int off, int len)使指针偏移达到跳转的效果。返回跳过实际字节数。
public long skip(long n) throws IOException {
return in.skip(n);
}
int available()
可以在不阻塞的情况下从这个输入流中读取(或跳过)的字节数的估计值。
public int available() throws IOException {
return in.available();
}
void close()
关闭此数据流
public void close() throws IOException {
in.close();
}
void mark(int readlimit)
由synchronized修饰
标记这个输入流中的当前位置并保存在readlimit中。对重置方法的后续调用将在最后一个标记的位置重新定位该流,以便随后的读取重新读取相同的字节。
public synchronized void mark(int readlimit) {
in.mark(readlimit);
}
void reset()
由synchronized修饰
将此流重新定位到在此输入流上最后调用标记方法时的位置。
public synchronized void reset() throws IOException {
in.reset();
}
boolean markSupported()
是否支持标记和重置是特定输入流实例的不变属性
public boolean markSupported() {
return in.markSupported();
}