org.w3c.www.mime
Class MultipartInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.w3c.www.mime.MultipartInputStream
All Implemented Interfaces:
java.io.Closeable

public class MultipartInputStream
extends java.io.InputStream

A class to handle multipart MIME input streams. See RC 1521. This class handles multipart input streams, as defined by the RFC 1521. It prvides a sequential interface to all MIME parts, and for each part it delivers a suitable InputStream for getting its body.


Constructor Summary
MultipartInputStream(java.io.InputStream in, byte[] boundary)
          Construct a new multipart input stream.
 
Method Summary
 int available()
           
 boolean nextInputStream()
          Switch to the next available part of data.
 int read()
          Read one byte of data from the current part.
 int read(byte[] b, int off, int len)
          Read n bytes of data from the current part.
 long skip(long n)
           
protected  boolean skipToBoundary()
           
 
Methods inherited from class java.io.InputStream
close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipartInputStream

public MultipartInputStream(java.io.InputStream in,
                            byte[] boundary)
Construct a new multipart input stream.

Parameters:
in - The initial (multipart) input stream.
boundary - The input stream MIME boundary.
Method Detail

skipToBoundary

protected boolean skipToBoundary()
                          throws java.io.IOException
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Read one byte of data from the current part.

Specified by:
read in class java.io.InputStream
Returns:
A byte of data, or -1 if end of file.
Throws:
java.io.IOException - If some IO error occured.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read n bytes of data from the current part.

Overrides:
read in class java.io.InputStream
Returns:
the number of bytes data, read or -1 if end of file.
Throws:
java.io.IOException - If some IO error occured.

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

nextInputStream

public boolean nextInputStream()
                        throws java.io.IOException
Switch to the next available part of data. One can interrupt the current part, and use this method to switch to next part before current part was totally read.

Returns:
A boolean true if there next partis ready, or false if this was the last part.
Throws:
java.io.IOException