📅  最后修改于: 2020-11-15 02:39:09             🧑  作者: Mango
java.io.ByteArrayInputStream类包含一个内部缓冲区,该缓冲区包含可以从流中读取的字节。内部计数器跟踪read方法要提供的下一个字节。以下是有关ByteArrayInputStream的要点-
关闭ByteArrayInputStream无效。
可以在关闭流之后调用此类中的方法,而不会产生IOException。
以下是java.io.ByteArrayInputStream类的声明-
public class ByteArrayInputStream
extends InputStream
以下是java.io.ByteArrayInputStream类的字段-
protected byte [] buf-这是流的创建者提供的字节数组。
protected int count-这是比输入流缓冲区中的最后一个有效字符大一个的索引。
protected int mark-这是流中当前标记的位置。
protected int pos-这是要从输入流缓冲区读取的下一个字符的索引。
Sr.No. | Constructor & Description |
---|---|
1 |
ByteArrayInputStream(byte[] buf) This creates a ByteArrayInputStream so that it uses buf as its buffer array. |
2 |
ByteArrayInputStream(byte[] buf, int offset, int length) This creates ByteArrayInputStream that uses buf as its buffer array. |
Sr.No. | Method & Description |
---|---|
1 | int available()
This method returns the number of remaining bytes that can be read (or skipped over) from this input stream. |
2 | void close()
Closing a ByteArrayInputStream has no effect. |
3 | void mark(int readAheadLimit)
This method set the current marked position in the stream. |
4 | boolean markSupported()
This method tests if this InputStream supports mark/reset. |
5 | int read()
This method reads the next byte of data from this input stream. |
6 | int read(byte[] b, int off, int len)
This method reads up to len bytes of data into an array of bytes from this input stream. |
7 | void reset()
This method resets the buffer to the marked position. |
8 | long skip(long n)
This method skips n bytes of input from this input stream. |
此类从以下类继承方法-