public class

SharedByteArrayInputStream

extends ByteArrayInputStream
implements SharedInputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.ByteArrayInputStream
       ↳ com.google.code.javax.mail.util.SharedByteArrayInputStream

Class Overview

A ByteArrayInputStream that implements the SharedInputStream interface, allowing the underlying byte array to be shared between multiple readers.

Summary

[Expand]
Inherited Constants
From class java.io.InputStream
Fields
protected int start Position within shared buffer that this stream starts at.
[Expand]
Inherited Fields
From class java.io.ByteArrayInputStream
Public Constructors
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 from offset for length bytes.
Public Methods
long getPosition()
Return the current position in the InputStream, as an offset from the beginning of the InputStream.
InputStream newStream(long start, long end)
Return a new InputStream representing a subset of the data from this InputStream, starting at start (inclusive) up to end (exclusive).
[Expand]
Inherited Methods
From class java.io.ByteArrayInputStream
From class java.io.InputStream
From class java.lang.Object
From interface com.google.code.javax.mail.internet.SharedInputStream
From interface java.io.Closeable

Fields

protected int start

Position within shared buffer that this stream starts at.

Public Constructors

public SharedByteArrayInputStream (byte[] buf)

Create a SharedByteArrayInputStream representing the entire byte array.

Parameters
buf The byte array

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 The byte array
offset Offset in byte array to first byte to include
length Number of bytes to include

Public Methods

public long getPosition ()

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

Returns
  • the current position

public InputStream newStream (long start, long end)

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 The starting position
end The ending position + 1
Returns
  • the new stream