org.norther.tammi.acorn.io
Class PartialInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.norther.tammi.acorn.io.PartialInputStream
All Implemented Interfaces:
Closeable

public class PartialInputStream
extends InputStream

An input stream wrapper for reading partial streams of multipart MIME messages as specified in RFC1521.

Version:
$Id: PartialInputStream.java,v 1.8 2009/09/28 15:08:49 cvsimp Exp $
Author:
Ilkka Priha

Constructor Summary
PartialInputStream(InputStream in, String boundary)
          Constructs a new partial input stream.
 
Method Summary
 int available()
          Returns the number of bytes available in the multipart stream.
 boolean isPartAvailable()
          Checks whether the next partial stream is available.
 int read()
          Reads one byte of data from the current part.
 int read(byte[] b, int off, int len)
          Reads n bytes of data from the current part.
 long skip(long n)
          Skips the given number of bytes.
 
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

PartialInputStream

public PartialInputStream(InputStream in,
                          String boundary)
Constructs a new partial input stream.

Parameters:
in - the multipart input stream.
boundary - the MIME boundary pattern.
Method Detail

available

public int available()
              throws IOException
Returns the number of bytes available in the multipart stream.

Overrides:
available in class InputStream
Returns:
the number of available bytes.
Throws:
IOException - for I/O errors.

read

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

Specified by:
read in class InputStream
Returns:
a byte of data, or -1 if end of file.
Throws:
IOException - for I/O errors.

read

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

Overrides:
read in class InputStream
Parameters:
b - a byte buffer.
off - an offet to the buffer.
len - the number of bytes to read.
Returns:
the number of bytes read or -1.
Throws:
IOException - for I/O errors.

skip

public long skip(long n)
          throws IOException
Skips the given number of bytes.

Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to skip.
Returns:
the number of bytes skipped.
Throws:
IOException - for I/O errors.

isPartAvailable

public boolean isPartAvailable()
                        throws IOException
Checks whether the next partial stream is available.

Returns:
true if available, false otherwise.
Throws:
IOException - for I/O errors.


Copyright © 2004 The Norther Organization. All rights reserved.