- java.lang.Object
- 
- java.io.InputStream
- 
- java.io.ByteArrayInputStream
- 
- jakarta.mail.util.SharedByteArrayInputStream
 
 
 
- 
- All Implemented Interfaces:
- SharedInputStream,- java.io.Closeable,- java.lang.AutoCloseable
 
 public class SharedByteArrayInputStream extends java.io.ByteArrayInputStream implements SharedInputStream A ByteArrayInputStream that implements the SharedInputStream interface, allowing the underlying byte array to be shared between multiple readers.- Author:
- Bill Shannon
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected intstartPosition within shared buffer that this stream starts at.
 - 
Constructor SummaryConstructors Constructor Description SharedByteArrayInputStream(byte[] buf)Create a SharedByteArrayInputStream representing the entire byte array.SharedByteArrayInputStream(byte[] buf, int offset, int length)Create a SharedByteArrayInputStream representing the part of the byte array fromoffsetforlengthbytes.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetPosition()Return the current position in the InputStream, as an offset from the beginning of the InputStream.java.io.InputStreamnewStream(long start, long end)Return a new InputStream representing a subset of the data from this InputStream, starting atstart(inclusive) up toend(exclusive).
 
- 
- 
- 
Constructor Detail- 
SharedByteArrayInputStreampublic SharedByteArrayInputStream(byte[] buf) Create a SharedByteArrayInputStream representing the entire byte array.- Parameters:
- buf- the byte array
 
 - 
SharedByteArrayInputStreampublic SharedByteArrayInputStream(byte[] buf, int offset, int length)Create a SharedByteArrayInputStream representing the part of the byte array fromoffsetforlengthbytes.- Parameters:
- buf- the byte array
- offset- offset in byte array to first byte to include
- length- number of bytes to include
 
 
- 
 - 
Method Detail- 
getPositionpublic long getPosition() Return the current position in the InputStream, as an offset from the beginning of the InputStream.- Specified by:
- getPositionin interface- SharedInputStream
- Returns:
- the current position
 
 - 
newStreampublic java.io.InputStream newStream(long start, long end)Return a new InputStream representing a subset of the data from this InputStream, starting atstart(inclusive) up toend(exclusive).startmust be non-negative. Ifendis -1, the new stream ends at the same place as this stream. The returned InputStream will also implement the SharedInputStream interface.- Specified by:
- newStreamin interface- SharedInputStream
- Parameters:
- start- the starting position
- end- the ending position + 1
- Returns:
- the new stream
 
 
- 
 
-