Top Description Fields Constructors Methods
javax.mail.util

public Class SharedByteArrayInputStream

extends ByteArrayInputStream
implements SharedInputStream
Class Inheritance
All Implemented Interfaces
javax.mail.internet.SharedInputStream
Imports
java.io.*, javax.mail.internet.SharedInputStream

A ByteArrayInputStream that implements the SharedInputStream interface, allowing the underlying byte array to be shared between multiple readers.
Author
Bill Shannon
Since
JavaMail 1.4

Field Summary

Modifier and TypeField and Description
protected int
start

Position within shared buffer that this stream starts at.

Inherited from java.io.ByteArrayInputStream:
bufcountmarkpos

Constructor Summary

AccessConstructor and Description
public
SharedByteArrayInputStream(byte[]
the byte array
buf
)

Create a SharedByteArrayInputStream representing the entire byte array.

public
SharedByteArrayInputStream(byte[]
the byte array
buf
,
int
offset in byte array to first byte to include
offset
,
int
number of bytes to include
length
)

Create a SharedByteArrayInputStream representing the part of the byte array from offset for length bytes.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the current position
getPosition
()

Implements javax.mail.internet.SharedInputStream.getPosition.

Return the current position in the InputStream, as an offset from the beginning of the InputStream.
public InputStream

Returns:

the new stream
newStream
(long
the starting position
start
,
long
the ending position + 1
end
)

Implements javax.mail.internet.SharedInputStream.newStream.

Return a new InputStream representing a subset of the data from this InputStream, starting at start (inclusive) up to end (exclusive).
Inherited from java.io.ByteArrayInputStream:
availableclosemarkmarkSupportedreadreadreadAllBytesreadNBytesresetskiptransferTo

Field Detail

startback to summary
protected int start

Position within shared buffer that this stream starts at.

Constructor Detail

SharedByteArrayInputStreamback to summary
public SharedByteArrayInputStream(byte[] buf)

Create a SharedByteArrayInputStream representing the entire byte array.

Parameters
buf:byte[]

the byte array

SharedByteArrayInputStreamback to summary
public SharedByteArrayInputStream(byte[] buf, int offset, int length)

Create a SharedByteArrayInputStream representing the part of the byte array from offset for length bytes.

Parameters
buf:byte[]

the byte array

offset:int

offset in byte array to first byte to include

length:int

number of bytes to include

Method Detail

getPositionback to summary
public long getPosition()

Implements javax.mail.internet.SharedInputStream.getPosition.

Return the current position in the InputStream, as an offset from the beginning of the InputStream.

Returns:long

the current position

Annotations
@Override
newStreamback to summary
public InputStream newStream(long start, long end)

Implements javax.mail.internet.SharedInputStream.newStream.

Return a new InputStream representing a subset of the data from this InputStream, starting at start (inclusive) up to end (exclusive). start must be non-negative. If end is -1, the new stream ends at the same place as this stream. The returned InputStream will also implement the SharedInputStream interface.

Parameters
start:long

the starting position

end:long

the ending position + 1

Returns:InputStream

the new stream

Annotations
@Override