Replace string at given index
public class Main { public static void main(String[] argv) throws Exception { StringBuffer buf = new StringBuffer("Java this is a test"); int start = 27; int end = 28; buf.replace(start, end, "4"); // Java Developers v1.4 System.out.println(buf); } }