org.yajul.io
Class TokenizingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.yajul.io.AbstractByteFilterInputStream
              extended by org.yajul.io.TokenizingInputStream
All Implemented Interfaces:
java.io.Closeable

public class TokenizingInputStream
extends AbstractByteFilterInputStream

Reads from the underlying input stream until the delimiter is reached. The read methods will return -1 (end of stream) when the delimiter is reached, or the end of the underlying stream has been reached. User: josh Date: Jan 18, 2004 Time: 10:00:01 AM


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
TokenizingInputStream(java.io.InputStream in, byte[] delimiter)
          Creates a FilterInputStream by assigning the argument in to the field this.in so as to remember it for later use.
 
Method Summary
 boolean endOfStream()
          Returns true if the end of the underlying stream was encountered.
 int getTokenCount()
          Returns the number of tokens matched so far.
 boolean nextToken()
          Resets the stream so a new token can be read.
 int read()
          Reads the next byte of data from this input stream.
 
Methods inherited from class org.yajul.io.AbstractByteFilterInputStream
insert, read, readByte
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenizingInputStream

public TokenizingInputStream(java.io.InputStream in,
                             byte[] delimiter)
Creates a FilterInputStream by assigning the argument in to the field this.in so as to remember it for later use.

Parameters:
delimiter - the delimiter
in - the underlying input stream, or null if this instance is to be created without an underlying stream.
Method Detail

read

public int read()
         throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method simply performs in.read() and returns the result.

Specified by:
read in class AbstractByteFilterInputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

endOfStream

public boolean endOfStream()
Returns true if the end of the underlying stream was encountered.

Returns:
true if the end of the underlying stream was encountered.

nextToken

public boolean nextToken()
Resets the stream so a new token can be read. Returns false if the end of the underlying stream was encountered, true if more tokens could be read.

Returns:
false if the end of the underlying stream was encountered.

getTokenCount

public int getTokenCount()
Returns the number of tokens matched so far.

Returns:
the number of tokens matched so far.


Copyright © 2008. All Rights Reserved.