DthingApi
Public Member Functions | Protected Attributes | List of all members
java.io.ByteArrayInputStream Class Reference
Inheritance diagram for java.io.ByteArrayInputStream:
java.io.InputStream

Public Member Functions

 ByteArrayInputStream (byte[] buf)
 
 ByteArrayInputStream (byte[] buf, int offset, int length)
 
synchronized int available ()
 
void close () throws IOException
 
synchronized void mark (int readlimit)
 
boolean markSupported ()
 
synchronized int read ()
 
synchronized int read (byte[] buffer, int offset, int length)
 
synchronized long skip (long byteCount)
 
synchronized void reset () throws IOException
 
- Public Member Functions inherited from java.io.InputStream
 InputStream ()
 
int available () throws IOException
 
void close () throws IOException
 
void mark (int readlimit)
 
boolean markSupported ()
 
abstract int read () throws IOException
 
int read (byte[] buffer) throws IOException
 
int read (byte[] buffer, int offset, int length) throws IOException
 
synchronized void reset () throws IOException
 
long skip (long byteCount) throws IOException
 

Protected Attributes

byte [] buf
 
int pos
 
int mark
 
int count
 

Detailed Description

A specialized InputStream for reading the contents of a byte array.

See also
ByteArrayOutputStream

Constructor & Destructor Documentation

◆ ByteArrayInputStream() [1/2]

java.io.ByteArrayInputStream.ByteArrayInputStream ( byte []  buf)
inline

Constructs a new

on the byte array

.

Parameters
bufthe byte array to stream over.

◆ ByteArrayInputStream() [2/2]

java.io.ByteArrayInputStream.ByteArrayInputStream ( byte []  buf,
int  offset,
int  length 
)
inline

Constructs a new

on the byte array

with the initial position set to

offset

and the number of bytes available set to

offset

+

length

.

Parameters
bufthe byte array to stream over.
offsetthe initial position in to start streaming from.
lengththe number of bytes available for streaming.

Member Function Documentation

◆ available()

synchronized int java.io.ByteArrayInputStream.available ( )
inline

Returns the number of remaining bytes.

Returns

◆ close()

void java.io.ByteArrayInputStream.close ( ) throws IOException
inline

Closes this stream and frees resources associated with this stream.

Exceptions
IOExceptionif an I/O error occurs while closing this stream.

◆ mark()

synchronized void java.io.ByteArrayInputStream.mark ( int  readlimit)
inline

Sets a mark position in this ByteArrayInputStream. The parameter

readlimit

is ignored. Sending

will reposition the stream back to the marked position.

Parameters
readlimitignored.
See also
markSupported()
reset()

◆ markSupported()

boolean java.io.ByteArrayInputStream.markSupported ( )
inline

Indicates whether this stream supports the

mark()

and

methods. Returns

true

since this class supports these methods.

Returns
always
true
.
See also
mark(int)
reset()

◆ read() [1/2]

synchronized int java.io.ByteArrayInputStream.read ( )
inline

Reads a single byte from the source byte array and returns it as an integer in the range from 0 to 255. Returns -1 if the end of the source array has been reached.

Returns
the byte read or -1 if the end of this stream has been reached.

◆ read() [2/2]

synchronized int java.io.ByteArrayInputStream.read ( byte []  buffer,
int  offset,
int  length 
)
inline

Reads at most

len

bytes from this stream and stores them in byte array

b

starting at

offset

. This implementation reads bytes from the source byte array.

Parameters
bufferthe byte array in which to store the bytes read.
offsetthe initial position in
b
to store the bytes read from this stream.
lengththe maximum number of bytes to store in
b
.
Returns
the number of bytes actually read or -1 if no bytes were read and the end of the stream was encountered.
Exceptions
IndexOutOfBoundsExceptionif
offset < 0
or
length < 0
, or if
offset + length
is greater than the size of
b
.
NullPointerExceptionif
b
is
null
.

◆ reset()

synchronized void java.io.ByteArrayInputStream.reset ( ) throws IOException
inline

Resets this stream to the last marked location. Throws an

IOException

if the number of bytes read since the mark has been set is greater than the limit provided to

, or if no mark has been set.

This implementation always throws an

IOException

and concrete subclasses should provide the proper implementation.

Exceptions
IOExceptionif this stream is closed or another IOException occurs.

◆ skip()

synchronized long java.io.ByteArrayInputStream.skip ( long  byteCount)
inline

Skips

byteCount

bytes in this InputStream. Subsequent calls to

will not return these bytes unless

is used. This implementation skips

byteCount

number of bytes in the target stream. It does nothing and returns 0 if

byteCount

is negative.

Returns
the number of bytes actually skipped.

Member Data Documentation

◆ buf

byte [] java.io.ByteArrayInputStream.buf
protected

The

byte

array containing the bytes to stream over.

◆ count

int java.io.ByteArrayInputStream.count
protected

The total number of bytes initially available in the byte array

.

◆ mark

int java.io.ByteArrayInputStream.mark
protected

The current mark position. Initially set to 0 or the offset parameter within the constructor.

◆ pos

int java.io.ByteArrayInputStream.pos
protected

The current position within the byte array.


The documentation for this class was generated from the following file: