org.codehaus.plexus.util

Class StringInputStream

public class StringInputStream extends InputStream

Deprecated: As of version 1.5.2 this class should no longer be used because it does not properly handle character encoding. Instead, wrap the output from String#getBytes(String) into a java.io.ByteArrayInputStream.

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.

Author: Magesh Umasankar

Constructor Summary
StringInputStream(String source)
Composes a stream from a String
Method Summary
voidclose()
Closes the Stringreader.
voidmark(int limit)
Marks the read limit of the StringReader.
booleanmarkSupported()
intread()
Reads from the Stringreader, returning the same value.
voidreset()
Resets the StringReader.

Constructor Detail

StringInputStream

public StringInputStream(String source)
Composes a stream from a String

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

Method Detail

close

public void close()
Closes the Stringreader.

Throws: 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

markSupported

public boolean markSupported()

See Also: InputStream#markSupported

read

public int read()
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: IOException if the original StringReader fails to be read

reset

public void reset()
Resets the StringReader.

Throws: IOException if the StringReader fails to be reset

Copyright © 2001-2010 Codehaus. All Rights Reserved.