public class BoundaryDelimitedInputStream extends FilterInputStream
BoundaryDelimitedInputStream
encapsulates a stream that is
sepearated into different sections by a common boundary, such as a MIME
multipart message. The full stream is referred to as the outer stream. Each
boundary separated section in the outer stream is referred to as an inner
stream.
All read() methods will start from the first inner stream, returning -1 when
a boundary is reached. Subsequent calls will then advance to the next stream,
skipping the boundary.in
Constructor and Description |
---|
BoundaryDelimitedInputStream(InputStream in,
byte[] boundary)
Constructs a
BoundaryDelimitedInputStream using the passed
InputStream as the source for the outer stream. |
Modifier and Type | Method and Description |
---|---|
int |
available()
This method will always return 0 because this input stream must
always read ahead to determine the location of the boundary.
|
void |
close()
Close this input stream, and its source input stream.
|
boolean |
isOuterStreamClosed()
Returns whether the outer stream is closed.
|
boolean |
markSupported()
Returns false.
|
void |
printLeftOvers() |
int |
read()
Reads a single byte from the inner input stream.
|
int |
read(byte[] b)
Reads from the inner input stream, attempting to fill the passed byte array.
|
int |
read(byte[] b,
int off,
int len)
Reads the specified number of bytes starting from the specified offset
into the specified buffer from the inner input stream.
|
long |
skip(long n)
Skips the specified number of bytes from the inner input stream.
|
mark, reset
public BoundaryDelimitedInputStream(InputStream in, byte[] boundary)
BoundaryDelimitedInputStream
using the passed
InputStream
as the source for the outer stream.in
- the source input streamboundary
- the byte boundary separating sections of this streampublic int available() throws IOException
available
in class FilterInputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
public boolean markSupported()
markSupported
in class FilterInputStream
public int read() throws IOException
InputStream
.read
in class FilterInputStream
IOException
public int read(byte[] b) throws IOException
InputStream
.read
in class FilterInputStream
b
- the byte array to populateb
, -1 on EOFIOException
public long skip(long n) throws IOException
InputStream
.skip
in class FilterInputStream
n
- the number of bytes to skipIOException
public int read(byte[] b, int off, int len) throws IOException
InputStream
.read
in class FilterInputStream
b
- the byte array to populateoff
- the offset in the array to start atlen
- the number of bytes to read, -1 on EOFIOException
public boolean isOuterStreamClosed()
public void printLeftOvers()
Copyright © 2018 JBoss by Red Hat. All rights reserved.