Provides the classes necessary to create an InputStream wrapper that allows substitution of one strings with another.
It can be used for initial cleansing of input data based on dictionary e.g.:
- \n => <br>
- & => &
Additional feature is ability to replace longest match - i.e. given dictionary:
- abc => three
- abcd => four
"This is as simple as abc or even abcd" will be transformed to
"This is as simple as three or even four" usage example:
... InputStream someInputStream = new FileInputStream(new File("filename")); FastReplaceInputStream wrappedInputStream = FastReplaceInputStream.builder() .withReplacement("\r\n", "\n") .withReplacement("Mr. ", "Sir ") .withReplacement("Mrs. ", "Madame ") .build(someInputStream); InputStreamReader reader = new InputStreamReader(wrappedInputStream); ...It will allow reading the file forcing Unix style newlines and replacing in flight set strings.