javax.mail.util
Class SharedByteArrayInputStream
java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
javax.mail.util.SharedByteArrayInputStream
- All Implemented Interfaces:
- Closeable, SharedInputStream
public class SharedByteArrayInputStream
- extends ByteArrayInputStream
- implements SharedInputStream
Field Summary |
protected int |
start
Position within shared buffer that this stream starts at. |
Method Summary |
long |
getPosition()
Get the position within the output stream, adjusted by the
starting offset. |
InputStream |
newStream(long offset,
long end)
Create a new input stream from this input stream, accessing
a subset of the data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
start
protected int start
- Position within shared buffer that this stream starts at.
SharedByteArrayInputStream
public SharedByteArrayInputStream(byte[] buf)
- Create a SharedByteArrayInputStream that shares the entire
buffer.
- Parameters:
buf
- The input data.
SharedByteArrayInputStream
public SharedByteArrayInputStream(byte[] buf,
int offset,
int length)
- Create a SharedByteArrayInputStream using a subset of the
array data.
- Parameters:
buf
- The source data array.offset
- The starting offset within the array.length
- The length of data to use.
getPosition
public long getPosition()
- Get the position within the output stream, adjusted by the
starting offset.
- Specified by:
getPosition
in interface SharedInputStream
- Returns:
- The adjusted position within the stream.
newStream
public InputStream newStream(long offset,
long end)
- Create a new input stream from this input stream, accessing
a subset of the data. Think of it as a substring operation
for a stream.
The starting offset must be non-negative. The end offset can
by -1, which means use the remainder of the stream.
- Specified by:
newStream
in interface SharedInputStream
- Parameters:
offset
- The starting offset.end
- The end offset (which can be -1).
- Returns:
- An InputStream configured to access the indicated data subrange.
Copyright © 2003-2008 The Apache Software Foundation. All Rights Reserved.