Example usage for java.lang String replace

List of usage examples for java.lang String replace

Introduction

In this page you can find the example usage for java.lang String replace.

Prototype

public String replace(CharSequence target, CharSequence replacement) 

Source Link

Document

Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.

Usage

From source file:Main.java

public static String removeHtmlTags(String toCleanString) {
    toCleanString = toCleanString.replace("<html>", "");
    toCleanString = toCleanString.replace("</html>", "");
    toCleanString = toCleanString.replace("<head></head>", "");
    toCleanString = toCleanString.replace("<body>", "");
    toCleanString = toCleanString.replace("</body>", "");
    return toCleanString.trim();
}

From source file:Main.java

/**
 * Converts a "simple" class name into a "binary" class name.  For
 * example://from  w w w . j  ava2 s .  co  m
 *
 *   SharedPreferences.Editor --&gt; SharedPreferences$Editor
 *
 * Do not use this on fully-qualified class names.
 */
public static String simpleClassNameToBinary(String className) {
    return className.replace('.', '$');
}

From source file:Main.java

/**
 * @param str A String that will be inserted into XML.
 * @return The String with special characters escaped. 
 *///from  ww w . ja v  a  2  s.  co m
public static String escapeSpecialCharacters(String str) {
    str = str.replace("&", "&amp;"); // & must be replaced first
    str = str.replace("<", "&lt;");
    str = str.replace(">", "&gt;");
    str = str.replace("\"", "&quot;");
    return str;
}

From source file:Main.java

public static String xmlEncode(String string) {

    return string.replace("&", "&amp;").replace("'", "&#39;").replace("\"", "&quot;").replace("<", "&lt;")
            .replace(">", "&gt;");
}

From source file:createbulksubdomainconfig.CreateBulkSubdomainConfig.java

protected synchronized static String getDbFileContent(String strDbUsrName, String strDbPwd, String strDbName) {
    //        System.out.println(strDbUsrName+"\t"+strDbName+"\t"+strDbPwd);
    String strTemp = mDatabase;
    strTemp = strTemp.replace("{{db_user_name}}", strDbUsrName);
    strTemp = strTemp.replace("{{db_pwd}}", strDbPwd);
    return strTemp.replace("{{db_name}}", strDbName);
}

From source file:Main.java

public static String convertClassToResourcePath(final String pName) {
    return pName.replace('.', '/') + ".class";
}

From source file:Main.java

public static String toPath(Context context) {
    String pn = getPackageName(context);
    pn = pn.replace("com.", "");
    return pn.replace(".", "/");
}

From source file:Main.java

/**
 * Removes the CDATA protection of an XML String
 * /*from  ww  w .  j a  va  2s.com*/
 * @param xml
 * @return the XML String without the CDATA protection
 */
public static String removeCData(String xml) {
    String cleanXML = xml.replace("<![CDATA[", "");
    cleanXML = cleanXML.replace("]]>", "");

    return cleanXML;
}

From source file:Main.java

public static String sescape(String str) {
    try {//from  w  ww.  ja va2  s  .co m
        return str.replace("'", "_").replace("\"", "_").replace(":", "_").replace("+", "_").replace("?", "_")
                .replace("!", "_").replace("#", "_").replace("(", "_").replace(")", "_").replace("{", "_")
                .replace("}", "_").replace("\\", "_").replace("&", "_").replace("\n", "_").replace("|", "_")
                .replace("*", "_").replace("/", "_").replace(",", "_");
    } catch (NullPointerException e) {
        return "unkown";
    }
}

From source file:org.bimserver.javamodelchecker.WriteToJson.java

private static String changeClassName(String code, String name) {
    return code.replace("public class " + name, "public class Implementation");
}