Package org.apache.james.mime4j.io
Class MimeBoundaryInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.james.mime4j.io.LineReaderInputStream
-
- org.apache.james.mime4j.io.MimeBoundaryInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class MimeBoundaryInputStream extends LineReaderInputStream
Stream that constrains itself to a single MIME body part. After the stream ends (i.e. read() returns -1)isLastPart()can be used to determine if a final boundary has been seen or not.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description MimeBoundaryInputStream(BufferedLineReaderInputStream inbuffer, String boundary)Creates a new MimeBoundaryInputStream.MimeBoundaryInputStream(BufferedLineReaderInputStream inbuffer, String boundary, boolean strict)Creates a new MimeBoundaryInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying stream.booleaneof()booleanisEmptyStream()booleanisFullyConsumed()booleanisLastPart()booleanmarkSupported()intread()intread(byte[] b, int off, int len)booleanreadAllowed()intreadLine(ByteArrayBuffer dst)Reads one line of text into the givenByteArrayBuffer.StringtoString()booleanunread(ByteArrayBuffer buf)Tries to unread the last read line.-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
MimeBoundaryInputStream
public MimeBoundaryInputStream(BufferedLineReaderInputStream inbuffer, String boundary, boolean strict) throws IOException
Creates a new MimeBoundaryInputStream.- Parameters:
inbuffer- The underlying stream.boundary- Boundary string (not including leading hyphens).- Throws:
IllegalArgumentException- when boundary is too longIOException
-
MimeBoundaryInputStream
public MimeBoundaryInputStream(BufferedLineReaderInputStream inbuffer, String boundary) throws IOException
Creates a new MimeBoundaryInputStream.- Parameters:
inbuffer- The underlying stream.boundary- Boundary string (not including leading hyphens).- Throws:
IllegalArgumentException- when boundary is too longIOException
-
-
Method Detail
-
close
public void close() throws IOExceptionCloses the underlying stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException- on I/O errors.
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classFilterInputStream- See Also:
InputStream.markSupported()
-
readAllowed
public boolean readAllowed() throws IOException- Throws:
IOException
-
read
public int read() throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException- See Also:
InputStream.read()
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
readLine
public int readLine(ByteArrayBuffer dst) throws IOException
Description copied from class:LineReaderInputStreamReads one line of text into the givenByteArrayBuffer.- Specified by:
readLinein classLineReaderInputStream- Parameters:
dst- Destination- Returns:
- number of bytes copied or
-1if the end of the stream has been reached. - Throws:
MaxLineLimitException- if the line exceeds a limit on the line length imposed by a subclass.IOException- in case of an I/O error.
-
isEmptyStream
public boolean isEmptyStream()
-
isFullyConsumed
public boolean isFullyConsumed()
-
isLastPart
public boolean isLastPart()
-
eof
public boolean eof()
-
unread
public boolean unread(ByteArrayBuffer buf)
Description copied from class:LineReaderInputStreamTries to unread the last read line. Implementation may refuse to unread a new buffer until the previous unread one has been competely consumed. Implementations will directly use the byte array backed by buf, so make sure to not alter it anymore once this method has been called.- Specified by:
unreadin classLineReaderInputStream- Returns:
- true if the unread has been succesfull.
-
-