org.apache.james.util
Class CharTerminatedInputStream

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

public class CharTerminatedInputStream
extends java.io.InputStream

An InputStream class that terminates the stream when it encounters a particular byte sequence.

Version:
1.0.0, 24/04/1999

Constructor Summary
CharTerminatedInputStream(java.io.InputStream in, char[] terminator)
          A constructor for this object that takes a stream to be wrapped and a terminating character sequence.
 
Method Summary
 int read()
          Read a byte off this stream.
 
Methods inherited from class java.io.InputStream
available, close, 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

CharTerminatedInputStream

public CharTerminatedInputStream(java.io.InputStream in,
                                 char[] terminator)
A constructor for this object that takes a stream to be wrapped and a terminating character sequence.

Parameters:
in - the InputStream to be wrapped
terminator - the array of characters that will terminate the stream.
Throws:
java.lang.IllegalArgumentException - if the terminator array is null or empty
Method Detail

read

public int read()
         throws java.io.IOException
Read a byte off this stream.

Specified by:
read in class java.io.InputStream
Returns:
the byte read off the stream
Throws:
java.io.IOException - if an IOException is encountered while reading off the stream
ProtocolException - if the underlying stream returns -1 before the terminator is seen.


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.