All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.io.StringReplaceReader

java.lang.Object
   |
   +----java.io.Reader
           |
           +----java.io.FilterReader
                   |
                   +----sdsu.io.StringReplaceReader

public class StringReplaceReader
extends FilterReader
implements Cloneable
Given a string pattern, a string replacementPattern and an input stream, this class will replace all occurances of pattern with replacementPattern in the inputstream. You can give multiple pattern-replacementPattern pairs. Multiple pairs are done in order they are given. If first pair is "cat"-"dog" and second pair is "dog"-"house", then the result will be all occurences of "cat" or "dog" will be replaced with "house".

Version:
0.6 21 August 1997
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Index

 o StringReplaceReader(InputStream, String, String)
Create an StringReplaceReader object that will replace all occurrences of pattern with replacementPattern in the inputstream in.
 o StringReplaceReader(Reader, String, String)
Create an StringReplaceReader object that will replace all occurrences ofpattern with replacementPattern in the Reader in.
 o StringReplaceReader(String, String, String)
Create an StringReplaceReader object that will replace all occurrences of pattern with replacementPattern in the string input.

Method Index

 o contents()
Returns the entire contents of the input stream.
 o eof()
Determines if a previous ASCII I/O operation caught End Of File.
 o read()
Returns the next character in the inputstream with string replacement done.
 o read(char[], int, int)
Read characters into a portion of an array.
 o replace(String, String)
Adds another pattern-replacementPattern pair.

Constructors

 o StringReplaceReader
 public StringReplaceReader(Reader in,
                            String pattern,
                            String replacementPattern)
Create an StringReplaceReader object that will replace all occurrences ofpattern with replacementPattern in the Reader in.

 o StringReplaceReader
 public StringReplaceReader(InputStream in,
                            String pattern,
                            String replacementPattern)
Create an StringReplaceReader object that will replace all occurrences of pattern with replacementPattern in the inputstream in.

 o StringReplaceReader
 public StringReplaceReader(String input,
                            String pattern,
                            String replacementPattern)
Create an StringReplaceReader object that will replace all occurrences of pattern with replacementPattern in the string input.

Methods

 o contents
 public String contents() throws IOException
Returns the entire contents of the input stream.

 o replace
 public void replace(String pattern,
                     String replacementPattern) throws OutOfMemoryError
Adds another pattern-replacementPattern pair. All occurrences of pattern will be replaced with replacementPattern.

Throws: OutOfMemoryError
if there is not enough memory to add new pattern-replacementPattern pair
 o read
 public int read(char buffer[],
                 int offset,
                 int charsToRead) throws IOException
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

Returns:
number of characters actually read, -1 if reah EOF on reading first character
Throws: IOException
if an I/O error occurs
Overrides:
read in class FilterReader
 o read
 public int read() throws IOException
Returns the next character in the inputstream with string replacement done.

Throws: IOException
if error occurs reading io stream
Overrides:
read in class FilterReader
 o eof
 public boolean eof()
Determines if a previous ASCII I/O operation caught End Of File.

Returns:
true if end of file was reached.

All Packages  Class Hierarchy  This Package  Previous  Next  Index