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:com.xiaoke.common.util.EncryptionUtil.java

/** 
  * UUID //from  w ww .ja  v a 2s. c o  m
  * @return String UUID 
  */
public static String getUUID() {
    String s = UUID.randomUUID().toString();
    //-?? 
    return s.replace("-", "");
}

From source file:net.sf.zekr.engine.search.SearchUtils.java

/**
 * Replace Farsi unicode <code>Yeh</code> with Arabic one, and so about <code>Kaf</code> (Farsi
 * <code>Keheh</code>)./*from  w  ww . jav  a  2  s  . c om*/
 * 
 * @param str
 * @return updated <code>String</code> result
 */
public static String replaceLayoutSimilarCharacters(String str) {
    str = str.replace(FARSI_YEH, ARABIC_YEH);
    str = str.replace(ALEF_MAKSURA, ARABIC_YEH);
    str = str.replace(FARSI_KEHEH, ARABIC_KAF);
    return str;
}

From source file:ReflectionUtil.java

private static String getPackageName(String clzName) {
    if (clzName.indexOf("/") == -1) {
        return null;
    }/*  w ww . j  a  v a2 s.  c o m*/
    String packageName = clzName.substring(0, clzName.lastIndexOf("/"));
    return packageName.replace("/", ".");
}

From source file:Main.java

/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 * //  w  w w.  j a  v  a  2 s.com
 * @param url the URL to parse
 * @return a dictionary bundle of keys and values
 */
public static Bundle parseUrl(String url) {
    // hack to prevent MalformedURLException
    url = url.replace("fbconnect", "http");
    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}

From source file:com.braffdev.server.core.utilities.ServerUtilities.java

/**
 * Returns a String representation of the given Throwable that can be used for displaying it in web browsers.<br />
 * In detail line breaks (\n) are being replaced by &lt;br /&gt; <br/>
 * and line feeds (\t) are being replaced by &amp;nbsp;&amp;nbsp;&amp;nbsp;
 *
 * @param e/*from ww  w.  ja  v  a 2  s . c om*/
 * @return
 */
public static String getStackTraceForWeb(Throwable e) {
    String stackTrace = ExceptionUtils.getStackTrace(e);
    stackTrace = stackTrace.replace("\n", "<br />");
    return stackTrace.replace("\t", "&nbsp;&nbsp;&nbsp;");
}

From source file:com.QuarkLabs.BTCeClientJavaFX.networking.App.java

public static JSONObject getPairInfo(String[] pairs) {
    String url = "https://btc-e.com/api/3/ticker/";
    for (String x : pairs) {
        url += x.replace("/", "_").toLowerCase() + "-";
    }//w  w w.j  ava 2 s  . c  o  m
    return new JSONObject(SimpleRequest.makeRequest(url));
}

From source file:net.sf.sprockets.database.sqlite.SQLite.java

/**
 * Get the name that the column was {@link #alias_(String) aliased} to.
 *//*from   w  ww .  j a  v  a2 s  .  co  m*/
public static String aliased_(String column) {
    return column.replace('.', '_');
}

From source file:Main.java

public static String fixHtmlText(String text) {
    if (text != null) {
        text = text.trim().replaceAll("\\\\+", "");
        text = text.replace("&amp;", "&");
        text = text.replace("&lt;", "<");
        text = text.replace("&gt;", ">");
        text = text.replace("&quot;", "\"");
    }/*ww  w .j  a v  a  2  s  . c  om*/
    text = Html.fromHtml(text).toString();
    return text;
}

From source file:UuidGenerator.java

/**
 * Ensures that the id is friendly for a URL or file system
 *
 * @param id the unique id/*from   ww w .j a v a  2s .  com*/
 * @return the id as file friendly id
 */
public static String generateSanitizedId(String id) {
    id = id.replace(':', '-');
    id = id.replace('_', '-');
    id = id.replace('.', '-');
    id = id.replace('/', '-');
    id = id.replace('\\', '-');
    return id;
}

From source file:it.larusba.neo4j.jdbc.http.driver.Neo4jStatement.java

/**
 * Escape method for cypher queries.//from   www. j  a  v a  2  s.  c om
 *
 * @param query Cypher query
 * @return
 */
public static String escapeQuery(String query) {
    return query.replace('\"', '\'').replace('\n', ' ');
}