com.caucho.vfs
Class StringReader

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.vfs.StringReader

public class StringReader
extends StreamImpl

A stream reading data from a string. The reader produces bytes using UTF-8.


Field Summary
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Method Summary
 boolean canRead()
          The string reader can always read.
 int getAvailable()
          Returns the number of characters available as an approximation to the number of bytes ready.
static ReadStream open(java.lang.String string)
          Creates a new ReadStream reading bytes from the given string.
 int read(byte[] buf, int offset, int length)
          Reads the next chunk from the stream.
 
Methods inherited from class com.caucho.vfs.StreamImpl
canWrite, clearWrite, close, closeWrite, flush, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, hasSkip, isClosed, isEof, readNonBlock, readTimeout, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

open

public static ReadStream open(java.lang.String string)
Creates a new ReadStream reading bytes from the given string.

Parameters:
string - the source string.
Returns:
a ReadStream reading from the string.

canRead

public boolean canRead()
The string reader can always read.

Overrides:
canRead in class StreamImpl

read

public int read(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Description copied from class: StreamImpl
Reads the next chunk from the stream.

Overrides:
read in class StreamImpl
Parameters:
buf - byte array receiving the data.
offset - starting offset into the array.
length - number of bytes to read.
Returns:
the number of bytes read or -1 on end of file.
Throws:
java.io.IOException

getAvailable

public int getAvailable()
                 throws java.io.IOException
Returns the number of characters available as an approximation to the number of bytes ready.

Overrides:
getAvailable in class StreamImpl
Throws:
java.io.IOException