Sample code for 30+ languages & platforms
Java

StringBuilder ReplaceWord

Demonstrates the ReplaceWord method.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    CkStringBuilder sb = new CkStringBuilder();
    sb.Append("forest, lumber, lumberjack, jack, timberland");

    //  The ReplaceWord method replaces word occurances.

    //  For example:
    int numReplacements = sb.ReplaceWord("lumber","timber");
    numReplacements = sb.ReplaceWord("jack","joe");

    //  The string content is now:
    //  forest, timber, lumberjack, joe, timberland
    System.out.println(sb.getAsString());
  }
}