Bytearrayinputstream of Java Byte stream

Source: Internet
Author: User

The role of Bytearrayinputstream:

Contains an internal buffer that contains bytes that can be read from the stream. The internal counter tracks read the next byte provided by the method. Close one ByteArrayInputStream without any effect. The methods in the stream can be called after the stream is closed, not generated IOException . This means that, for example, a file stream handles a file in the external memory of an object, and its processing object is an in-memory buffer. It is read from one memory to another in memory mode.

Fields
Modifier and Type Field Description
protected byte[] buf An array of bytes provided by the creator of the data stream.
protected int count Index one is greater than the last valid character in the input stream buffer.
protected int mark The position of the current marker in the stream.
protected int pos The index of the next character read from the input stream buffer.
construction method  
constructor Description
Bytearrayinputstream? (byte[] buf) Bytearrayinputstream that uses buf as its buffer array.
By Tearrayinputstream? (Byte[] buf, Int offset, int length) Create bytearrayinputstream use buf as its buffer array.
Modifier and Type Method Description
int available?() Returns the number of bytes remaining that can be read (or skipped) from this input stream.
void close?() Close one ByteArrayInputStream without any effect.
void mark?(int readAheadLimit) Sets the position of the current marker in the stream.
boolean markSupported?() Test this InputStream support tag/reset.
int read?() Reads the next data byte from the input stream.
int read?(byte[] b, int off, int len) Reads up len to a byte array of data from the input stream.
void reset?() Resets the buffer to the marker position.
long skip?(long n) Skips the byte input of this input stream n .

Note:

Public bytearrayinputstream? (byte[] buf,  int offset, int length)
Create ByteArrayInputStreamUse bufAs its buffer array. posIs offsetAnd the initial value, countis the smallest offset+lengthAnd buf.length。 The buffer array is not copied. The marker for the buffer is set to the specified offset.
Parameters
buf -Input buffer.
offset -The offset in the buffer to read the first byte.
length -The maximum number of bytes read from the buffer.

Bytearrayinputstream of Java Byte stream

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.