List of usage examples for java.lang StringBuilder StringBuilder
@HotSpotIntrinsicCandidate
public StringBuilder()
From source file:Main.java
public static <T> String join(T[] array, String join) { StringBuilder builder = new StringBuilder(); for (T t : array) { builder.append(t);/*from w ww . ja va 2s. c om*/ builder.append(join); } return builder.deleteCharAt(builder.length() - 1).toString(); }
From source file:Main.java
private static String bytesToHexV2(byte[] data) { StringBuilder buf = new StringBuilder(); for (byte b : data) { int halfbyte = (b >>> 4) & 0x0F; int two_halfs = 0; do {/*from w w w .ja va 2 s . c o m*/ buf.append((0 <= halfbyte) && (halfbyte <= 9) ? (char) ('0' + halfbyte) : (char) ('a' + (halfbyte - 10))); halfbyte = b & 0x0F; } while (two_halfs++ < 1); } return buf.toString(); }
From source file:Main.java
private static String byteToHexString(byte[] digest) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < digest.length; i++) { String hex = Integer.toHexString(0xFF & digest[i]); if (hex.length() == 1) { sb.append('0'); }// w w w . ja v a 2 s . com sb.append(hex); } return sb.toString(); }
From source file:Main.java
public static String getSessionId() { StringBuilder s = new StringBuilder(); for (int i = 8; i-- > 0;) { s.append(getSessionComponent()); switch (i) { case 1:/*from ww w .ja v a 2s . c om*/ case 3: case 5: case 7: s.append("-"); break; } } return s.toString(); }
From source file:Main.java
public static String formatPhone(String phone) { StringBuilder result = new StringBuilder(); if (phone != null && phone.length() == 11) { String prefix = "+86 "; result.append(prefix);/* w ww. jav a 2 s.c o m*/ result.append(phone.substring(0, 3)).append(" "); result.append(phone.substring(3, 7)).append(" "); result.append(phone.substring(7)); } return result.toString(); }
From source file:Main.java
private static String projection(String[] projection) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < projection.length; i++) { sb.append(projection[i]);//from w w w .ja v a 2s.c om if (i != projection.length - 1) { sb.append(","); } } return sb.toString(); }
From source file:Main.java
public static String join(String[] array, String delimiter) { StringBuilder sb = new StringBuilder(); for (String str : array) { sb.append(str);/*from ww w . ja v a 2 s. c o m*/ sb.append(delimiter); } return sb.toString(); }
From source file:Main.java
public static String timeFormat(int ms) { StringBuilder time = new StringBuilder(); time.delete(0, time.length());/* w w w . ja v a2 s.co m*/ ms /= 1000; int s = ms % 60; int min = ms / 60; if (min < 10) { time.append(0); } time.append(min).append(":"); if (s < 10) { time.append(0); } time.append(s); return time.toString(); }
From source file:Main.java
public static String floatArrayToString(float[] array) { StringBuilder builder = new StringBuilder(); for (float v : array) { builder.append("" + v + " "); }/*from ww w . j a v a 2 s . co m*/ builder.append("\n"); return builder.toString(); }
From source file:Main.java
private static String toHexString(byte[] bytes) { StringBuilder hexString = new StringBuilder(); for (byte b : bytes) { String str = Integer.toHexString(0xFF & b); while (str.length() < 2) { str = "0" + str; }/*from w w w. j av a2 s. c o m*/ hexString.append(str); } return hexString.toString(); }