public class FilterInputStream extends InputStream
FilterInputStream
包含一些其他输入流,它使用作为其基本数据源,可能改变数据沿道路或提供额外的功能。这类
FilterInputStream
本身只是重写,过去的所有请求的版本包含输入流
InputStream
所有方法。子
FilterInputStream
可能进一步覆盖其中的一些方法也可以提供额外的方法和字段。
Modifier and Type | Field and Description |
---|---|
protected InputStream |
in
要过滤的输入流。
|
Modifier | Constructor and Description |
---|---|
protected |
FilterInputStream(InputStream in)
通过指定参数
in 到外地
this.in 以便记住它以后使用创建一个
FilterInputStream 。
|
Modifier and Type | Method and Description |
---|---|
int |
available()
返回一个可以从这个输入流读取(或跳过)的字节数的估计值,而不阻塞该输入流的下一个调用方的方法。
|
void |
close()
关闭此输入流并释放与流关联的任何系统资源。
|
void |
mark(int readlimit)
标记此输入流中的当前位置。
|
boolean |
markSupported()
如果输入流的支持
mark 和
reset 方法。
|
int |
read()
从这个输入流读取下一个数据字节。
|
int |
read(byte[] b)
读到
byte.length 字节从输入流到字节数组数据。
|
int |
read(byte[] b, int off, int len)
读到
len 从输入流到字节数组数据字节。
|
void |
reset()
重新定位该流在时间的
mark 方法的位置上呼吁这个输入流。
|
long |
skip(long n)
跳过并丢弃
n 字节输入流中的数据。
|
protected volatile InputStream in
protected FilterInputStream(InputStream in)
in
到外地
this.in
以便记住它以后使用创建一个
FilterInputStream
。
in
-潜在的输入流,或
null
如果此实例被创建,没有潜在的流。
public int read() throws IOException
0
一
int
到
255
返回。如果没有可用的字节,因为已到达流的末尾,则返回值
-1
。此方法块,直到输入数据可用,流的结束被检测到,或抛出异常。
该方法简单in.read()
执行并返回结果。
read
方法重写,继承类
InputStream
-1
如果到达流的末尾。
IOException
如果I/O错误发生。
in
public int read(byte[] b) throws IOException
byte.length
从输入流到字节数组数据字节。该方法块,直到有一个输入可用。
此方法只需执行呼叫read(b, 0, b.length)
并返回结果。它不做in.read(b)
取而代之的是重要的;某些子类的FilterInputStream
取决于实施策略的实际应用。
read
方法重写,继承类
InputStream
b
-缓冲区中读取数据。
-1
如果没有更多的数据,因为已到达流的末尾。
IOException
如果I/O错误发生。
read(byte[], int, int)
public int read(byte[] b, int off, int len) throws IOException
len
从输入流到字节数组数据字节。如果
len
不为零,该方法阻塞直到输入可用;否则,没有字节读取和
0
返回。
该方法简单in.read(b, off, len)
执行并返回结果。
read
方法重写,继承类
InputStream
b
-缓冲区中读取数据。
off
-开始抵消目标数组
b
len
-的最大字节数读。
-1
如果没有更多的数据,因为已到达流的末尾。
null
b
NullPointerException
。
IndexOutOfBoundsException
-如果
off
是负的,
len
是负的,或
len
大于
b.length - off
IOException
如果I/O错误发生。
in
public long skip(long n) throws IOException
n
字节输入流中的数据。
skip
方法的可能,因为种种原因,最终跳过一些较小的字节数,可能
0
。跳过的字节数实际返回。
此方法只需执行in.skip(n)
。
skip
方法重写,继承类
InputStream
n
-字节数被跳过。
IOException
如果流不支持查找,或者其他一些发生I/O错误。
public int available() throws IOException
此方法返回的结果available() in
。
available
方法重写,继承类
InputStream
IOException
如果I/O错误发生。
public void close() throws IOException
in.close()
。
close
接口
Closeable
close
接口
AutoCloseable
close
方法重写,继承类
InputStream
IOException
如果I/O错误发生。
in
public void mark(int readlimit)
reset
方法重新定位该流的最后标记的位置以便后续读重读相同的字节。
争论的readlimit
告诉这个输入流,使许多字节在标记位置获取无效阅读。
此方法只需执行in.mark(readlimit)
。
mark
方法重写,继承类
InputStream
readlimit
-字节可以在标记位置无效阅读最大限度。
in
,
reset()
public void reset() throws IOException
mark
方法的位置上呼吁这个输入流。
此方法只需执行in.reset()
。
流标记的目的是要使用的情况下,你需要阅读前面的一点,看看什么在流中。通常这是最容易通过调用一些通用的解析器来完成的。如果流是由解析处理的类型,它只是遵循着幸福。如果流不是该类型的,则解析器失败时应将其抛出一个异常。如果这发生在readlimit字节,它允许外码重置流并尝试另一个解析器。
reset
方法重写,继承类
InputStream
IOException
如果流不明显或者商标已失效。
in
,
mark(int)
public boolean markSupported()
mark
和
reset
方法。此方法只需执行
in.markSupported()
。
markSupported
方法重写,继承类
InputStream
true
流类型支持
mark
和
reset
方法;
false
否则。
in
,
InputStream.mark(int)
,
InputStream.reset()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.