org.apache.tools.ant.filters
Class StringInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.apache.tools.ant.filters.StringInputStream

public class StringInputStream
extends java.io.InputStream

Wraps a String as an InputStream.

Author:
Magesh Umasankar

Constructor Summary
StringInputStream(java.lang.String source)
          Composes a stream from a String
StringInputStream(java.lang.String source, java.lang.String encoding)
          Composes a stream from a String with the specified encoding
 
Method Summary
 int available()
           
 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.
 int read(byte[] b, int off, int len)
          Reads from the Stringreader into a byte array
 void reset()
          Resets the StringReader.
 
Methods inherited from class java.io.InputStream
read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

StringInputStream

public StringInputStream(java.lang.String source,
                         java.lang.String encoding)
Composes a stream from a String with the specified encoding

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

read

public int read()
         throws java.io.IOException
Reads from the Stringreader, returning the same value.

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

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads from the Stringreader into a byte array

Overrides:
read in class java.io.InputStream
Parameters:
b - the byte array to read into
off - the offset in the byte array
len - the length in the byte array to fill
Returns:
the actual number read into the byte array, -1 at the end of the stream
Throws:
java.io.IOException - if an error occurs

mark

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

Overrides:
mark in class java.io.InputStream
Parameters:
limit - the maximum limit of bytes that can be read before the mark position becomes invalid

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Returns:
the current number of bytes ready for reading
Throws:
java.io.IOException - if an error occurs

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream
Returns:
false - mark is not supported

reset

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

Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException - if the StringReader fails to be reset

close

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

Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - if the original StringReader fails to be closed


Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.