Class Replacer


public class Replacer
extends java.lang.Object
Multiple string search and replace utility. This class accepts any number of search+replace string pairs to be added. It can then operate on either an input String or stream and replace all occurances of any search pattern with its corresponding replace string.

Example that does html > and < encoding:

 Replacer htmlEscaper = new Replacer();
 htmlEscaper.add("<", "&lt;");
 htmlEscaper.add(">", "&gt;");
 String escapedString = replacer.replace(aHtmlString);
  • Constructor Summary

    Constructor Description
  • Method Summary

    Modifier and Type Method Description
    void add​(java.lang.String search, java.lang.String replace)  
    void processStreams​( in2, out2)  
    java.lang.String replace​(java.lang.String s)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • add

      public void add​(java.lang.String search, java.lang.String replace)
    • processStreams

      public void processStreams​( in2, out2) throws
    • replace

      public java.lang.String replace​(java.lang.String s)