com.cc.framework.util
Class StringInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended bycom.cc.framework.util.StringInputStream

public class StringInputStream
extends java.io.InputStream

Wraps a String as an InputStream. Note that data will be lost for characters not in ISO Latin 1, as a simple char->byte mapping is assumed.

Version:
$Revision: 1.7 $
Author:
Harald Schulz

Field Summary
private  java.io.StringReader in
          Source string, stored as a StringReader
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
StringInputStream(java.lang.String source)
          Composes a stream from a String
 
Method Summary
 void close()
          Closes the StringReader.
 void mark(int limit)
          Marks the read limit of the StringReader.
 boolean markSupported()
           
 int read()
          Reads from the StringReader, returning the same value.
 void reset()
          Resets the StringReader.
 
Methods inherited from class java.io.InputStream
available, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

private java.io.StringReader in
Source string, stored as a StringReader

Constructor Detail

StringInputStream

public StringInputStream(java.lang.String source)
Composes a stream from a String

Parameters:
source - The string to read from. Must not be null.
Method Detail

read

public int read()
         throws java.io.IOException
Reads from the StringReader, returning the same value. Note that data will be lost for characters not in ISO Latin 1. Clients assuming a return value in the range -1 to 255 may even fail on such input.

Returns:
the value of the next character in the StringReader
Throws:
java.io.IOException - if the original StringReader fails to be read

close

public void close()
           throws java.io.IOException
Closes the StringReader.

Throws:
java.io.IOException - if the original StringReader fails to be closed

mark

public void mark(int limit)
Marks the read limit of the StringReader.

Parameters:
limit - the maximum limit of bytes that can be read before the mark position becomes invalid

reset

public void reset()
           throws java.io.IOException
Resets the StringReader.

Throws:
java.io.IOException - if the StringReader fails to be reset

markSupported

public boolean markSupported()
See Also:
InputStream.markSupported()


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.