List of usage examples for java.lang StringBuilder StringBuilder
@HotSpotIntrinsicCandidate
public StringBuilder()
From source file:Main.java
public static String makeCommaSepratedString(List<String> list, String delim) { StringBuilder sb = new StringBuilder(); String loopDelim = ""; for (String s : list) { sb.append(loopDelim);/*from w w w .ja v a 2 s .co m*/ sb.append(s); loopDelim = delim; } return sb.toString(); }
From source file:Main.java
public static String sanitizeToLineFeed(CharSequence string) { StringBuilder sb = new StringBuilder(); for (int i = 0, len = string.length(); i < len; i++) { char c = string.charAt(i); boolean legal = c == '\u0009' || c == '\n' || (c >= '\u0020' && c <= '\uD7FF') || (c >= '\uE000' && c <= '\uFFFD'); if (legal) { sb.append(c);/*from www .j av a 2 s .c o m*/ } } return sb.toString(); }
From source file:Main.java
public static String getQueryDateFormat(String datestr) { String[] substrings = datestr.split("/"); return String.valueOf(new StringBuilder().append(substrings[2]).append("-").append(substrings[0]) .append("-").append(substrings[1])); }
From source file:Main.java
public static String NewCode() { StringBuilder sb = new StringBuilder(); sb.append(random.nextInt(10));//from ww w.ja va2s . c om sb.append(random.nextInt(10)); sb.append(random.nextInt(10)); sb.append(random.nextInt(10)); return sb.toString(); }
From source file:Main.java
public static String generateRandom() { Random number = new Random(); StringBuilder message = new StringBuilder(); for (int i = 0; i < 1405; i++) { message.append('a' + number.nextInt(52)); }/*from www .ja v a 2 s. c o m*/ return message.toString(); }
From source file:Main.java
public static String getStringByStringBuilder(String... strings) { StringBuilder builder = new StringBuilder(); for (String string : strings) { builder.append(string);//from w w w.j a v a 2 s . c o m } return builder.toString(); }
From source file:Main.java
public static String changeImageParam(String url, String param) { if (url != null) { StringBuilder sb = new StringBuilder(); if (url.contains("?")) { sb.append(url.substring(0, url.indexOf("?"))); } else {/*from w ww . j a va 2 s. c om*/ sb.append(url); } if (param != null) { sb.append(param); } return sb.toString(); } return null; }
From source file:Main.java
private static String toHex(byte[] results) { if (results == null) return null; StringBuilder hexString = new StringBuilder(); for (int i = 0; i < results.length; i++) { int hi = (results[i] >> 4) & 0x0f; int lo = results[i] & 0x0f; hexString.append(Character.forDigit(hi, 16)).append(Character.forDigit(lo, 16)); }//from w w w . ja va 2 s. c om return hexString.toString(); }
From source file:Main.java
public static String getOnlyNumerics(String str) { if (str == null) return null; StringBuilder strBuff = new StringBuilder(); char c;/*w w w. j a v a 2 s . co m*/ for (int i = 0; i < str.length(); i++) { c = str.charAt(i); if (Character.isDigit(c)) strBuff.append(c); } return strBuff.toString(); }
From source file:Main.java
public static String escapeJava(String doco) { if (doco == null) return ""; StringBuilder b = new StringBuilder(); for (char c : doco.toCharArray()) { if (c == '\r') b.append("\\r"); else if (c == '\n') b.append("\\n"); else if (c == '"') b.append("'"); else/* w w w. j a va2 s. c o m*/ b.append(c); } return b.toString(); }