List of usage examples for java.lang StringBuilder StringBuilder
@HotSpotIntrinsicCandidate
public StringBuilder()
From source file:Main.java
public static String xmlFilter(String input) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '<') { sb.append("<"); } else if (c == '>') { sb.append(">"); } else if (c == '\'') { sb.append("'"); } else if (c == '"') { sb.append("""); } else if (c == '&') { sb.append("&"); } else {//from w ww . j a v a2 s. com sb.append(c); } } return sb.toString(); }
From source file:Main.java
public static String toStringWithLength(byte[] b, int pos, int length) { StringBuilder str = new StringBuilder(); for (int i = 0; i < length; i++) { str.append((char) b[pos + i]); }/*from ww w .ja v a 2s. c o m*/ String ret = str.toString(); return ret; }
From source file:Main.java
public static String scanByteToHexString(byte[] scanRecord) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < scanRecord.length; i++) { int v = scanRecord[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0);/*w w w . ja v a 2 s . c om*/ } stringBuilder.append(hv); } return stringBuilder.toString(); }
From source file:Main.java
public static String parseShortTime(int ms) { StringBuilder builder = new StringBuilder(); int hour = ms / 1000 / 3600; if (hour > 0) { if (hour < 10) { builder.append("0"); }// w w w .j ava 2 s. co m builder.append(hour); builder.append(":"); } int minute = ms / 1000 % 3600 / 60; if (minute < 10) { builder.append("0"); } builder.append(minute); builder.append(":"); int second = ms / 1000 % 3600 % 60; if (second < 10) { builder.append("0"); } builder.append(second); return builder.toString(); }
From source file:Main.java
public static <T> String toString(List<T> values) { StringBuilder buffer = new StringBuilder(); for (T value : values) { buffer.append(value).append(System.lineSeparator()); }/* w ww . jav a 2 s . c o m*/ return buffer.toString(); }
From source file:Main.java
public static String getUtteranceId(String packageName, long notificationId) { StringBuilder utteranceId = new StringBuilder(); utteranceId.append(notificationId).append("_").append(packageName); return utteranceId.toString(); }
From source file:Main.java
public static String getQualifiedMethodName(Method method) { return (new StringBuilder()).append(method.getDeclaringClass().getName()).append(".") .append(method.getName()).toString(); }
From source file:Main.java
public static String int2ip(long ipInt) { StringBuilder sb = new StringBuilder(); sb.append(ipInt & 0xFF).append("."); sb.append((ipInt >> 8) & 0xFF).append("."); sb.append((ipInt >> 16) & 0xFF).append("."); sb.append((ipInt >> 24) & 0xFF); return sb.toString(); }
From source file:Main.java
public static String bytesToAddress(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("%02X:", b)); }/*from ww w . ja va2 s . c om*/ sb.deleteCharAt(sb.length() - 1); // remove last semicolon return sb.toString(); }
From source file:Main.java
public static String asCSV(List<String> strings) { StringBuilder s = new StringBuilder(); boolean first = true; for (String n : strings) { if (!first) s.append(","); s.append(n);/*from ww w . j a va2 s .c om*/ first = false; } return s.toString(); }