ByteBufferInputStream

public class ByteBufferInputStream extends InputStream

A ByteBufferInputStream contains an internal buffer that contains direct or non-direct byte buffer that may be read from the stream. Creation Date: 24/10/2006

Author:Twinsen Tsang

Fields

buf

protected ByteBuffer buf

The internal byte buffer.

Constructors

ByteBufferInputStream

public ByteBufferInputStream(ByteBuffer buffer)

Creates a ByteBufferInputStream so that it uses buf as its byte buffer. The buffer array is not copied.

Parameters:
  • buf – the input buffer.

Methods

available

public int available()

Returns the number of bytes that can be read from this input stream without blocking. The value returned is limit of byte buffer. which is the number of bytes remaining to be read from the input buffer.

Returns:the number of bytes that can be read from the input stream without blocking.

close

public void close()

Close the stream.

getChannel

public ReadableByteChannel getChannel()

Returns the readable byte channel object associated with this byte buffer input stream.

Returns:a readable byte channel for this byte buffer.

See also: java.nio.channels.Channels

mark

public synchronized void mark(int readlimit)

Mark this stream.

markSupported

public boolean markSupported()

Mark is support by this InputStream.

Returns:always true

read

public int read()

Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned.

read

public int read(byte[] b)

read

public int read(byte[] b, int off, int len)

reset

public synchronized void reset()

Resets the buffer to the marked position. The marked position is 0 unless another position was marked or an offset was specified in the constructor.