List of usage examples for java.lang String replace
public String replace(CharSequence target, CharSequence replacement)
From source file:Main.java
public static String getShortWeekdayName(int day) { if (day < 1 || day > 7) throw new IndexOutOfBoundsException("Invalid index, value must be between 1 and 7"); String dayName = dateFormatSymbols.getShortWeekdays()[day]; return dayName.replace(dayName.charAt(0), Character.toUpperCase(dayName.charAt(0))); }
From source file:Main.java
/** Join the specified string with the specified separator. * Any other instances of pSeparator are doubled. * * @param pArgs the strings to be quoted * @param pSeparator the character to use as a separator * * @return the joined string, with quoting. *//* ww w.ja v a2s.c om*/ public static String joinStringsWithQuoting(String[] pStrings, char pSeparator) { if ((pStrings == null) || (pStrings.length == 0)) { return ""; } String strSingle = Character.toString(pSeparator); String strDouble = strSingle + strSingle; StringBuilder sb = new StringBuilder(); boolean bFirstTime = false; for (String strCur : pStrings) { sb.append(strCur.replace(strSingle, strDouble)); if (!bFirstTime) { sb.append(strSingle); } else { bFirstTime = false; } } return sb.toString(); }
From source file:Main.java
/** * Gets the characters name from the filename by stripping the prefix. * @return The characters name if prefixed correctly, null otherwise. *///from w w w .j a v a2s. co m public static String getCharacterNameFromFilename(String filename) { if (filename.startsWith(CORE_PREFIX)) { return filename.replace(CORE_PREFIX, ""); } else if (filename.startsWith(FAE_PREFIX)) { return filename.replace(FAE_PREFIX, ""); } return null; }
From source file:Main.java
public static String getStringPreview(String str) { String preview;//from w w w . j a v a2 s .co m if (str.length() < 29) { preview = str.replace("\n", " "); } else { preview = str.replace("\n", " ").substring(0, 29) + "..."; } return preview; }
From source file:Main.java
/** * Avoid ' in JS function calls/*from w ww . j av a 2 s.c o m*/ * @param args * @return */ public static String formatJsArgs(String args) { if (args == null) { return null; } return args.replace("'", "\\'"); }
From source file:net.longfalcon.taglib.TextFunctions.java
public static String nl2br(String s) { s = s.replace("\r\n", "<br/>"); s = s.replace("\r", "<br/>"); s = s.replace("\n", "<br/>"); return s;/*from w w w . j a v a 2s.c o m*/ }
From source file:Main.java
private static String toUnixLineEnding(String s) { if (s == null) { return null; }//from ww w . j a v a 2 s. c o m return s.replace("\r\n", "\n"); }
From source file:Main.java
public static String encode(char delimiter, Iterable<String> parts) { StringBuilder result = new StringBuilder(); for (String part : parts) { String encodedPart = part.replace("\\", "\\\\"); encodedPart = encodedPart.replace("" + delimiter, "\\" + delimiter); result.append(encodedPart);/*www . j a va 2s.c om*/ result.append(delimiter); } return result.toString(); }
From source file:Main.java
public static String makeCurrentTimestampedFolderName() { Date maintenant = new Date(); SimpleDateFormat formatDateJour = new SimpleDateFormat("yyyy-MM-dd_kk-mm-ss"); String dateFormatee = formatDateJour.format(maintenant); return PREFIX_FOLDER + "/." + dateFormatee.replace("-", ""); }
From source file:Main.java
/** * Translates avatar id to string that can be used by disc cache as file name. * @param avatarId Avatar ID.// w ww . j a va 2 s . c o m * @return Key/file name for disk cache. */ public static String getDiskCacheKey(final String avatarId) { if (!TextUtils.isEmpty(avatarId)) { return avatarId.replace("|", "").toLowerCase(); } return null; }