public static String replaceText(String originalStr, String oldStr,
            String newStr) {
        if (oldStr == null || newStr == null || oldStr.equals(newStr)) {
            return originalStr;
        }
        StringBuffer result = new StringBuffer(originalStr);
        int startIndex = 0;
        while ((startIndex = result.indexOf(oldStr, startIndex)) != -1) {
            result = result.replace(startIndex, startIndex + oldStr.length(),
                    newStr);
            startIndex += newStr.length();
        }
        return result.toString();
    }