| 构造方法 |
|---|
| ByteArrayInputStream(byte[] buf)
创建一个 ByteArrayInputStream ,使其使用 buf作为其缓冲区数组。 |
| ByteArrayInputStream(byte[] buf, int offset, int length)
创建 ByteArrayInputStream使用buf作为其缓冲器阵列 offset指定位置开始,length指定字节长度 |
| 返回类型 | 方法描述 |
|---|---|
| int | available()
返回可从此输入流读取(或跳过)的剩余字节数。 |
| void | close()
关闭 ByteArrayInputStream没有任何效果。 |
| void | mark(int readAheadLimit)
设置流中当前标记的位置。 |
| boolean | markSupported()
测试 InputStream是否支持标记/复位。 |
| int | read()
从该输入流读取下一个数据字节。 |
| int | read(byte[] b, int off, int len)
将 len字节的数据读入此输入流中的字节数组。 |
| void | reset()
将缓冲区重置为标记位置。 |
| long | skip(long n)
从此输入流跳过 n个字节的输入。 |
byte[] barr = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
try (ByteArrayInputStream bais = new ByteArrayInputStream(barr);) {
int i;
while (bais.available() > 0) {
i = bais.read();
System.out.print(i + " ");
}
} catch (IOException e) {
System.out.println(e.getMessage());
}