List of usage examples for java.lang StringBuilder StringBuilder
@HotSpotIntrinsicCandidate
public StringBuilder()
From source file:Main.java
public static final String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String hex = Integer.toHexString(bytes[i] & 0xFF); if (hex.length() == 1) { hex = '0' + hex; }/*from ww w.j a va2 s.co m*/ sb.append(hex); } return sb.toString(); }
From source file:Main.java
public static String generateConnectKey(String host, int port) { StringBuilder sb = new StringBuilder(); sb.append(host);//from w w w . j av a 2s .co m sb.append(":"); sb.append(String.valueOf(port)); return sb.toString(); }
From source file:Main.java
public static String addStrings(Object... params) { StringBuilder stringBuilder = new StringBuilder(); for (Object s : params) { stringBuilder.append(s);//from w w w . j a v a 2 s .c om } return stringBuilder.toString(); }
From source file:Main.java
public static String hexEncode(byte[] aInput) { StringBuilder result = new StringBuilder(); char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; for (int idx = 0; idx < aInput.length; ++idx) { byte b = aInput[idx]; result.append(digits[(b & 0xf0) >> 4]); result.append(digits[b & 0x0f]); }/* ww w . j a v a 2s . c o m*/ return result.toString(); }
From source file:Main.java
public static String getThemeAlphaColor(int alpha) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("#"); stringBuilder.append(String.format("%02x", alpha * 255 / 100)); stringBuilder.append("12B7F5"); return stringBuilder.toString(); }
From source file:Main.java
public static String toStringWithComma(String[] array) { StringBuilder sb = new StringBuilder(); if (array != null) { for (int i = 0; i < array.length; i++) { sb.append(array[i]);/*w ww .j a v a 2 s. c o m*/ if (i < array.length - 1) sb.append(","); } } return sb.toString(); }
From source file:Main.java
public static String getClassFullName(String pkg, String name) { StringBuilder sb = new StringBuilder(); if (pkg.length() != 0) { sb.append(pkg).append("."); }// ww w. j a v a 2 s . c o m sb.append(name); return sb.toString(); }
From source file:Main.java
public static String convert(String utfString) { StringBuilder sb = new StringBuilder(); int i = -1;/* w w w . ja va2 s . c om*/ int pos = 0; while ((i = utfString.indexOf("\\u", pos)) != -1) { sb.append(utfString.substring(pos, i)); if (i + 5 < utfString.length()) { pos = i + 6; sb.append((char) Integer.parseInt(utfString.substring(i + 2, i + 6), 16)); } } return sb.toString(); }
From source file:Main.java
public static String implode(Iterable it, String glue) { StringBuilder result = new StringBuilder(); for (Object o : it) { result.append(glue).append(o);// ww w. j a va2s . c o m } if (result.length() > 0) { result.delete(0, glue.length()); } return result.toString(); }
From source file:Main.java
public static String convertArrayToString(String[] array) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < array.length; i++) { sb.append(array[i]);//from w w w.ja va 2s . c o m // Do not append comma at the end of last element if (i < array.length - 1) { sb.append("-"); } } return sb.toString(); }