ewe.io
Class StringStream

java.lang.Object
  extended byewe.util.Errorable
      extended byewe.io.BasicStreamObject
          extended byewe.io.StreamObject
              extended byewe.io.RandomStreamObject
                  extended byewe.io.MemoryFile
                      extended byewe.io.StringStream
All Implemented Interfaces:
BasicRandomAccessStream, BasicStream, FastStream, RandomAccessStream, Stream, Streamable

public class StringStream
extends MemoryFile

This is a Stream that you can use if you have a String that you need to read from as a Stream, or if you need to write to a Stream and then have the data you wrote converted into a String.

You would probably be better off using a StringWriter instead.


Field Summary
 
Fields inherited from class ewe.io.MemoryFile
data, mode
 
Fields inherited from class ewe.io.StreamObject
napIterations, napTime, READWRITE_CLOSED, READWRITE_ERROR, READWRITE_WOULDBLOCK
 
Fields inherited from class ewe.io.BasicStreamObject
closed
 
Fields inherited from class ewe.util.Errorable
error
 
Constructor Summary
StringStream()
          Create a new empty StringStream() ready for writing to.
StringStream(byte[] textData, int start, int length, String mode)
          Create a new StringStream() which initially contains text and which can be read from and/or written to.
StringStream(String text)
          Create a new StringStream() for reading only, initially containing the specified text.
StringStream(String text, String mode)
          Create a new StringStream() which initially contains text and which can be read from and/or written to.
 
Method Summary
 String toString()
          Return as a String, all the text data that was written into the Stream.
 
Methods inherited from class ewe.io.MemoryFile
canWrite, createFrom, flushStream, getFilePosition, getLength, isOpen, nonBlockingRead, nonBlockingWrite, quickRead, quickWrite, seek, setStreamLength
 
Methods inherited from class ewe.io.RandomStreamObject
getStreamLength, length, nonBlockingRead, nonBlockingWrite, seek, seekPosition, setLength, tell, tellPosition, toRandomStream
 
Methods inherited from class ewe.io.StreamObject
close, closeStream, doRead, doWrite, flush, nap, nap, read, readAByte, readBytes, readBytes, write, writeAByte, writeBytes, writeBytes
 
Methods inherited from class ewe.io.BasicStreamObject
getException, getName, read, read, throwIOException, toInputStream, toOutputStream, toStream, write, write
 
Methods inherited from class ewe.util.Errorable
returnError, returnError, returnError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 
Methods inherited from interface ewe.io.BasicStream
close, closeStream
 
Methods inherited from interface ewe.io.Stream
flush, read, read, read, readBytes, readBytes, toInputStream, toOutputStream, write, write, write, writeBytes, writeBytes
 

Constructor Detail

StringStream

public StringStream()
Create a new empty StringStream() ready for writing to.


StringStream

public StringStream(String text)
Create a new StringStream() for reading only, initially containing the specified text.

Parameters:
text - The text initially stored in the stream.

StringStream

public StringStream(byte[] textData,
                    int start,
                    int length,
                    String mode)
Create a new StringStream() which initially contains text and which can be read from and/or written to.

Parameters:
textData - The initial text, encoded data as bytes.
start - The start of the text in textData.
length - The number of bytes to use from textData.
mode - either "r" or "rw".

StringStream

public StringStream(String text,
                    String mode)
Create a new StringStream() which initially contains text and which can be read from and/or written to.

Parameters:
text - The initial text in the stream. This will be UTF8 encoded and stored as bytes in the Stream.
mode - either "r" or "rw".
Method Detail

toString

public String toString()
Return as a String, all the text data that was written into the Stream.

Overrides:
toString in class Object
Returns:
a String representing this object.