List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:Main.java
/** * Replace a string that contains wildcards (* and ?) to its regular expression equivalent. * @param wildcardString the string to convert. * @return the regular expression equivalent to the wildcard string. *//* w ww .j a v a 2 s. c o m*/ public static String convertWildcardsToRegExp(String wildcardString) { return "\\Q" + wildcardString.replace("\\E", "\\\\E").replace("\\Q", "\\\\Q").replace("?", "\\E.\\Q") .replace("*", "\\E.*\\Q"); }
From source file:Main.java
public static String getThumbUrl(String videoUrl) { videoUrl = videoUrl.replace("swf/", ""); int index = videoUrl.indexOf("video/"); if (index != -1) { return "http://www.abewy.com/apps/klyph/services/content_from_url.php?url=" + videoUrl.substring(0, index) + "thumbnail/" + videoUrl.substring(index); }/*from w w w . j a va 2s. co m*/ return ""; }
From source file:Main.java
public static String RenameFileToNewPath(String oldpath) { String path = oldpath; path = path.replace("/mnt/sdcard/", ""); String new_path = path.replace(".ck", ""); File sdcard = Environment.getExternalStorageDirectory(); File from = new File(sdcard, oldpath); File to = new File(sdcard, new_path); from.renameTo(to);/* w w w . j av a 2 s . c om*/ return to.toString(); }
From source file:Main.java
public static String replaceBr(String old) { return old.replace("\\021", "\\r\\n"); }
From source file:Main.java
public static String AddLineBody(String input) { return input.replace("\r\n", "</p><p>"); }
From source file:Main.java
public static byte[] string2bytes(String s) { String ss = s.replace(" ", ""); int string_len = ss.length(); int len = string_len / 2; if (string_len % 2 == 1) { ss = "0" + ss; string_len++;//w w w . j av a2 s . c o m len++; } byte[] a = new byte[len]; for (int i = 0; i < len; i++) { a[i] = (byte) Integer.parseInt(ss.substring(2 * i, 2 * i + 2), 16); } return a; }
From source file:Main.java
/** * Reversre operation of Arrays.toString(int[]) * @param str [1, 2, 3, 4, 5]// w ww . j a v a 2 s. co m * @return */ public static int[] fromString(String str) { String[] strings = str.replace("[", "").replace("]", "").split(","); int result[] = new int[strings.length]; for (int i = 0; i < result.length; i++) { result[i] = Integer.parseInt(strings[i].trim()); } return result; }
From source file:createbulksubdomainconfig.CreateBulkSubdomainConfig.java
protected synchronized static String getConfigFileContent(String strFolderName) { String strTemp = mConfig; strTemp = strTemp.replace("{{base_url}}", strFolderName); // return strTemp.replace("{{encrypt_key}}", new BigInteger(24, new SecureRandom()).toString(32)); return strTemp.replace("{{encrypt_key}}", RandomStringUtils.randomAlphanumeric(16)); }
From source file:Main.java
/** * Replace all single quotes by quotation marks. This is use-ful for writing xml string constants e. g. in test cases. * <node name='name' locale='en'/> is transformed to <node name="name" locale="en"/> * @param xml//from ww w .j av a2s . c o m * @return */ public static String replaceQuotes(final String xml) { final String text = xml.replace('\'', '"'); return text; }
From source file:Main.java
public static String xmlEncode(String str) { return str.replace("&", "&").replace("<", "<").replace("<", ">").replace("\"", """) .replace("'", "'"); }