FileDocCategorySizeDatePackage
Replace.javaAPI DocExample585Mon Oct 30 12:56:50 GMT 2000None

Replace

public class Replace extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		System.out.println(
			replace("lazy", "supine", "A quick bronze fox lept a lazy bovine"));
		System.out.println(
			replace("$DIR", "/home/ian", "$DIR/xxx"));
	
public static java.lang.Stringreplace(java.lang.String oldStr, java.lang.String newStr, java.lang.String inString)

		int start = inString.indexOf(oldStr);
		if (start == -1) {
			return inString;
		}
		StringBuffer sb = new StringBuffer();
		sb.append(inString.substring(0, start));
		sb.append(newStr);
		sb.append(inString.substring(start+oldStr.length()));
		return sb.toString();