org.apache.james.mime4j
Class MimeBoundaryInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.james.mime4j.MimeBoundaryInputStream
All Implemented Interfaces:
java.io.Closeable

public class MimeBoundaryInputStream
extends java.io.InputStream

Stream that constrains itself to a single MIME body part. After the stream ends (i.e. read() returns -1) hasMoreParts() can be used to determine if a final boundary has been seen or not. If parentEOF() is true an unexpected end of stream has been detected in the parent stream.

Version:
$Id: MimeBoundaryInputStream.java,v 1.2 2004/11/29 13:15:42 ntherning Exp $

Constructor Summary
MimeBoundaryInputStream(java.io.InputStream s, java.lang.String boundary)
          Creates a new MimeBoundaryInputStream.
 
Method Summary
 void close()
          Closes the underlying stream.
 void consume()
          Consumes all unread bytes of this stream.
 boolean hasMoreParts()
          Determines if the underlying stream has more parts (this stream has not seen an end boundary).
 boolean parentEOF()
          Determines if the parent stream has reached EOF
 int read()
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeBoundaryInputStream

public MimeBoundaryInputStream(java.io.InputStream s,
                               java.lang.String boundary)
                        throws java.io.IOException
Creates a new MimeBoundaryInputStream.

Parameters:
s - The underlying stream.
boundary - Boundary string (not including leading hyphens).
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Closes the underlying stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - on I/O errors.

hasMoreParts

public boolean hasMoreParts()
Determines if the underlying stream has more parts (this stream has not seen an end boundary).

Returns:
true if there are more parts in the underlying stream, false otherwise.

parentEOF

public boolean parentEOF()
Determines if the parent stream has reached EOF

Returns:
true if EOF has been reached for the parent stream, false otherwise.

consume

public void consume()
             throws java.io.IOException
Consumes all unread bytes of this stream. After a call to this method this stream will have reached EOF.

Throws:
java.io.IOException - on I/O errors.

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read()


Copyright © 2004-2007 The Apache Software Foundation. All Rights Reserved.