List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:Main.java
protected static String generateRandomContainerName() { String containerName = "container" + UUID.randomUUID().toString(); return containerName.replace("-", ""); }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager phoneMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String tel = phoneMgr.getLine1Number(); if (tel != null) { tel = tel.replace("+86", "").trim(); }//ww w . ja v a 2s .c om return tel; }
From source file:com.oncore.calorders.rest.service.helper.ContactHelper.java
public static void setAddressZipCode(Address address, String zipCode) { zipCode = zipCode.replace("-", ""); address.setAdrZip5(StringUtils.substring(zipCode, 0, 5)); if (zipCode.length() == 9) { address.setAdrZip4(StringUtils.substring(zipCode, 5, 9)); }//from w ww .j a va 2 s. c o m }
From source file:Main.java
public static String getFormattedAmount(double amount) { try {//from w w w . j a va2 s . co m String amountString = new DecimalFormat("#,###").format(amount); return amountString.replace(",", "."); } catch (NumberFormatException e) { return "" + amount; } catch (NullPointerException e) { return "" + amount; } }
From source file:Main.java
/** * Escapes special HTML entities/*from w w w . j a v a 2s .c o m*/ * @param text * @return text with HTML entities escaped */ public static String escapeXMLEntities(String text) { if (text == null) return null; text = text.replace("&", "&"); text = text.replace("\"", """); text = text.replace("<", "<"); text = text.replace(">", ">"); text = text.replace("'", "'"); return text; }
From source file:cc.aileron.commons.util.HtmlUtils.java
/** * @param value//from ww w . j av a 2 s . co m * @return value */ public static String nl2br(final String value) { return "\n" + value.replace("\r\n", "<br />").replace("\r", "<br />").replace("\n", "<br />"); }
From source file:com.xwiki.authentication.guanxi.StringUtils.java
/** * Clean the incomming string to XWiki name standards * * @param String to clean/*from ww w .j av a2 s. c o m*/ * @param String to use as replacement * @return String valid string */ public static String makeValid(String s, String r) { s.replace(".", r); //s.replace("@",r); return s; }
From source file:Main.java
public static List<String> getDexEntries() { try {//from w ww . j a v a 2 s . c o m Object app = Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null); Object codePath = Class.forName("android.app.Application").getMethod("getPackageCodePath").invoke(app); Class<?> dexFileClass = Class.forName("dalvik.system.DexFile"); Object dexFile = dexFileClass.getConstructor(String.class).newInstance(codePath); Enumeration<String> entries = (Enumeration<String>) dexFileClass.getMethod("entries").invoke(dexFile); List<String> dexEntries = new LinkedList<>(); while (entries.hasMoreElements()) { String entry = entries.nextElement(); entry = entry.replace('.', '/') + ".class"; dexEntries.add(entry); } dexFileClass.getMethod("close").invoke(dexFile); return dexEntries; } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException e) { throw new RuntimeException(e); } }
From source file:de.arraying.arraybot.util.UFormatting.java
/** * Removes all mass mentions from the input. * @param input The input.//w w w. j av a2 s .co m * @return A stripped string. */ public static String removeMentions(String input) { return input.replace("@here", "@\u180ehere").replace("@everyone", "@\u180eeveryone"); }
From source file:Main.java
private static String removeExtraSlashes(final String str) { if (str.contains("//")) { return removeExtraSlashes(str.replace("//", "/")); } else {// w ww .ja va 2s. co m return str; } }