public final class BoundaryDelimitedInputStream extends FilterInputStream
BoundaryDelimitedInputStream encapsulates a stream that is separated 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.
|
void |
setBoundary(byte[] boundary)
Sets a new boundary to delimit the stream by.
|
long |
skip(long n)
Skips the specified number of bytes from the inner input stream.
|
mark, resetpublic 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 FilterInputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterInputStreamIOExceptionpublic boolean markSupported()
markSupported in class FilterInputStreampublic int read()
throws IOException
InputStream.read in class FilterInputStreamIOExceptionpublic int read(byte[] b)
throws IOException
InputStream.read in class FilterInputStreamb - the byte array to populateb, -1 on EOFIOExceptionpublic long skip(long n)
throws IOException
InputStream.skip in class FilterInputStreamn - the number of bytes to skipIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
InputStream.read in class FilterInputStreamb - the byte array to populateoff - the offset in the array to start atlen - the number of bytes to read, -1 on EOFIOExceptionpublic boolean isOuterStreamClosed()
public void setBoundary(byte[] boundary)
boundary - public void printLeftOvers()
Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.