List of usage examples for java.lang StringBuilder StringBuilder
@HotSpotIntrinsicCandidate
public StringBuilder()
From source file:Main.java
public static String arrayToString(String[] array, String delimiter) { StringBuilder sb = new StringBuilder(); if (array.length > 0) { sb.append(array[0]);// w w w. j av a 2 s .c o m for (int i = 1; i < array.length; i++) { sb.append(delimiter); sb.append(array[i]); } } return sb.toString(); }
From source file:Main.java
public static String unicodeToChinese(String unicode) { StringBuilder out = new StringBuilder(); if (!isBlank(unicode)) { for (int i = 0; i < unicode.length(); i++) { out.append(unicode.charAt(i)); }//from w w w . j a v a 2s. c om } return out.toString(); }
From source file:Main.java
public static String joinArray(ArrayList arr) { StringBuilder sb = new StringBuilder(); for (Object obj : arr) { sb.append(obj);/*from w w w . j av a 2 s . c o m*/ } return sb.toString(); }
From source file:Main.java
public static String implodeInt(int[] list) { String sep = ","; StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.length; i++) { sb.append(Integer.toString(list[i])); if (i != list.length - 1) { sb.append(sep);//from w w w. j a v a 2 s. co m } } return sb.toString(); }
From source file:Main.java
public static String joinTasks(CharSequence delimiter, int[] ids) { StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (int i = 0; i < ids.length; i++) { if (firstTime) { firstTime = false;//from ww w . j av a 2 s .c om } else { sb.append(delimiter); } sb.append(ids[i]); } return sb.toString(); }
From source file:Main.java
public static String ubytesToString(byte[] data, int offset, int len) { StringBuilder sb = new StringBuilder(); if (len > 0) { int p = offset; sb.append(data[p++] & 0xFF); for (int i = 1; i < len; ++i) { sb.append(',').append(data[p++] & 0xFF); }/*from ww w . ja v a 2s . co m*/ } return sb.toString(); }
From source file:Main.java
public static String generateStringContentType(final String charset) { StringBuilder buffer = new StringBuilder(); buffer.append("application/x-www-form-urlencoded"); if (charset != null) { buffer.append("; charset="); buffer.append(charset);// w w w . java2 s . c o m } return buffer.toString(); }
From source file:Main.java
public static String printBundle(Bundle bundle) { StringBuilder sb = new StringBuilder(); for (String key : bundle.keySet()) { sb.append("\nkey:" + key + ", value:" + bundle.getString(key)); }// ww w . j a va 2 s . com return sb.toString(); }
From source file:Main.java
public static String shortsToString(short[] data, int offset, int len) { StringBuilder sb = new StringBuilder(); if (len > 0) { int p = offset; sb.append(data[p++]);// w w w . j a v a2s .c o m for (int i = 1; i < len; ++i) { sb.append(',').append(data[p++]); } } return sb.toString(); }
From source file:Main.java
public static String ubytesToString16(byte[] data, int offset, int len) { StringBuilder sb = new StringBuilder(); if (len > 0) { int p = offset; sb.append(Integer.toHexString(data[p++] & 0xFF)); for (int i = 1; i < len; ++i) { sb.append(',').append(Integer.toHexString(data[p++] & 0xFF)); }/*from w w w . j a v a 2s .c o m*/ } return sb.toString(); }