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 org.w3c.dom.Document getTweetsByKeywords(String keywords) {
    keywords = keywords.replace(' ', '+');
    return getXMLDocument(SEARCH_REQUEST_LOCATION_URL + keywords);

}

From source file:org.infinitest.eclipse.markers.ResourceLookupAdapter.java

private static String sourceFilename(String className) {
    return className.replace(".", "/") + ".java";
}

From source file:Main.java

public static String removeSpaces(String str) {
    if (str == null) {
        return null;
    }//  w ww . j av a2 s .  c  o  m
    str.replace(" ", "");
    str = str.trim();
    return str;
}

From source file:Main.java

public static String addSetString(String fieldName) {
    if (fieldName.startsWith("is")) {
        return fieldName.replace("is", "set");
    }//from   w  w w .j  a  va 2s .com
    StringBuffer sb = new StringBuffer();
    sb.append("set");
    sb.append(fieldName.substring(0, 1).toUpperCase());
    sb.append(fieldName.substring(1));
    return sb.toString();
}

From source file:cc.aileron.commons.util.HtmlUtils.java

/**
 * @param value/*from  w ww .jav  a 2  s  . c  o m*/
 * @return value
 */
public static String space2nbsp(final String value) {
    return value.replace(" ", " ");
}

From source file:com.wdhis.util.ReplaceStrUtils.java

public static String replaceStr(String str) {

    String locationStr = str.replace("_", "[_]");
    System.out.println(locationStr);

    return locationStr;
}

From source file:BostonAccentDemo.java

private static void bostonAccent(String sentence) {
    char r = 'r';
    char h = 'h';
    String translatedSentence = sentence.replace(r, h);
    System.out.println(translatedSentence);
}

From source file:Main.java

public static long getToday() {
    Calendar cal = Calendar.getInstance();
    String curDate = dateFormater2.get().format(cal.getTime());
    curDate = curDate.replace("-", "");
    return Long.parseLong(curDate);
}

From source file:Main.java

public static String getExtension(String fileName) {
    int lastDotPosition = fileName.lastIndexOf(".");
    String ext = fileName.substring(lastDotPosition + 1);
    ext = ext.replace("_", "");
    return ext.trim().toLowerCase();
}

From source file:Main.java

public static String getMenuSectionImageUri(String menuItem) {
    menuItem = menuItem.toLowerCase();/*  w  w w .  jav a 2  s.  c  o  m*/
    menuItem = menuItem.replace(" ", "_");
    if (menuImages != null && !menuImages.isEmpty() && menuImages.containsKey(menuItem)) {
        return menuImages.get(menuItem);
    }
    return "";
}