com.imagero.uio.io
Class StringArrayReader

java.lang.Object
  extended byjava.io.Reader
      extended bycom.imagero.uio.io.StringArrayReader

public class StringArrayReader
extends java.io.Reader

A character stream whose source is a string array. Very similar to java.io.StringReader.


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
StringArrayReader(java.lang.String[] s)
          Create a new StringArrayReader.
 
Method Summary
 void close()
          Close the stream.
 void mark(int readAheadLimit)
          Mark the present position in the stream.
 boolean markSupported()
          Tell whether this stream supports the mark() operation.
 int read()
          Read a single character.
 int read(char[] cbuf, int off, int len)
          Read characters into a portion of supplied char array.
 boolean ready()
          Tell whether this stream is ready to be read.
 void reset()
          Reset the stream to the most recent mark, or to the beginning of the string if it has never been marked.
 long skip(long ns)
          Skip characters.
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringArrayReader

public StringArrayReader(java.lang.String[] s)
Create a new StringArrayReader.

Parameters:
s - String array providing the character stream.
Method Detail

read

public int read()
         throws java.io.IOException
Read a single character.

Returns:
The character read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Read characters into a portion of supplied char array.

Parameters:
cbuf - Destination char array
off - Where to start writing characters
len - Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs

skip

public long skip(long ns)
          throws java.io.IOException
Skip characters.

Throws:
java.io.IOException - If an I/O error occurs

ready

public boolean ready()
              throws java.io.IOException
Tell whether this stream is ready to be read.

Returns:
True if the next read() is guaranteed not to block for input
Throws:
java.io.IOException - If the stream is closed

markSupported

public boolean markSupported()
Tell whether this stream supports the mark() operation.

Returns:
true

mark

public void mark(int readAheadLimit)
          throws java.io.IOException
Mark the present position in the stream. Subsequent calls to reset() will reposition the stream to this point.

Parameters:
readAheadLimit - Limit on the number of characters that may be read while still preserving the mark.
Throws:
java.lang.IllegalArgumentException - If readAheadLimit is < 0
java.io.IOException - If an I/O error occurs

reset

public void reset()
           throws java.io.IOException
Reset the stream to the most recent mark, or to the beginning of the string if it has never been marked.

Throws:
java.io.IOException - If an I/O error occurs

close

public void close()
Close the stream.