Top Fields Constructors Methods
org.bouncycastle.mail.smime.util

public Class SharedFileInputStream

extends FilterInputStream
implements SharedInputStream
Class Inheritance
All Implemented Interfaces
javax.mail.internet.SharedInputStream
Imports
javax.mail.internet.SharedInputStream, java.io.BufferedInputStream, .File, .FileInputStream, .FilterInputStream, .IOException, .InputStream, java.util.Iterator, .LinkedList, .List

Field Summary

Modifier and TypeField and Description
private final File
private final long
private long
private final SharedFileInputStream
private long
private final long
private List<E>
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
public
private
SharedFileInputStream(File file, long start, long length)

private
SharedFileInputStream(SharedFileInputStream parent, long start, long length)

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Close of this stream and any substreams that have been created from it.

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.

public SharedFileInputStream

Returns:

the base of the shared stream tree.
getRoot
()

Return the shared stream that represents the top most stream that this stream inherits from.

public void
mark(int
the maximum limit of bytes that can be read before the mark position becomes invalid.
readLimit
)

Overrides java.io.FilterInputStream.mark.

Marks the current position in this input stream.

public boolean
markSupported()

Overrides java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

public InputStream
newStream(long
the starting position
start
,
long
the ending position + 1
finish
)

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).

public int
read(byte[]
the buffer into which the data is read.
buf
)

Overrides java.io.FilterInputStream.read.

Reads up to b.length bytes of data from this input stream into an array of bytes.

public int
read(byte[]
the buffer into which the data is read.
buf
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public void
reset()

Overrides java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

public long
skip(long
the number of bytes to be skipped.
n
)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.

Inherited from java.io.FilterInputStream:
availableclose

Field Detail

_fileback to summary
private final File _file
_lengthback to summary
private final long _length
_markedPositionback to summary
private long _markedPosition
_parentback to summary
private final SharedFileInputStream _parent
_positionback to summary
private long _position
_startback to summary
private final long _start
_subStreamsback to summary
private List<E> _subStreams

Constructor Detail

SharedFileInputStreamback to summary
public SharedFileInputStream(String fileName) throws IOException
SharedFileInputStreamback to summary
public SharedFileInputStream(File file) throws IOException
SharedFileInputStreamback to summary
private SharedFileInputStream(File file, long start, long length) throws IOException
SharedFileInputStreamback to summary
private SharedFileInputStream(SharedFileInputStream parent, long start, long length) throws IOException

Method Detail

disposeback to summary
public void dispose() throws IOException

Close of this stream and any substreams that have been created from it.

Exceptions
IOException:
on problem closing the main stream.
getPositionback to summary
public long getPosition()

Implements javax.mail.internet.SharedInputStream.getPosition.

Doc from 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

getRootback to summary
public SharedFileInputStream getRoot()

Return the shared stream that represents the top most stream that this stream inherits from.

Returns:SharedFileInputStream

the base of the shared stream tree.

markback to summary
public void mark(int readLimit)

Overrides java.io.FilterInputStream.mark.

Doc from java.io.FilterInputStream.mark.

Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

Parameters
readLimit:int

the maximum limit of bytes that can be read before the mark position becomes invalid.

markSupportedback to summary
public boolean markSupported()

Overrides java.io.FilterInputStream.markSupported.

Doc from java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

Returns:boolean

true if this stream type supports the mark and reset method; false otherwise.

newStreamback to summary
public InputStream newStream(long start, long finish)

Implements javax.mail.internet.SharedInputStream.newStream.

Doc from 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

finish:long

the ending position + 1

Returns:InputStream

the new stream

readback to summary
public int read(byte[] buf) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Parameters
buf:byte[]

the buffer into which the data is read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] buf, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
buf:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the 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. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs.
resetback to summary
public void reset() throws IOException

Overrides java.io.FilterInputStream.reset.

Doc from java.io.FilterInputStream.reset.

Repositions this stream to the position at the time the mark method was last called on this input stream.

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Exceptions
IOException:
if this stream has not been marked or if the mark has been invalidated.
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Exceptions
IOException:
if in.skip(n) throws an IOException.