List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
private static byte[] generateDigest(String algorithm, String... params) throws NoSuchAlgorithmException { StringBuilder sb = new StringBuilder(512); for (String s : params) { sb.append(s); }/*from w w w . ja v a 2 s. c o m*/ return MessageDigest.getInstance(algorithm).digest(sb.toString().getBytes()); }
From source file:Main.java
public static String toString(Intent intent) { StringBuilder sb = new StringBuilder(); sb.append(intent.getAction()).append(" "); Bundle bundle = intent.getExtras();/*from ww w. j a v a2 s . c o m*/ if (bundle != null) { Set<String> sets = bundle.keySet(); for (String key : sets) { if (bundle.get(key) instanceof Integer) { sb.append(key).append(":").append(bundle.getInt(key)).append("\n"); } else if (bundle.get(key) instanceof ArrayList) { sb.append(key).append(":").append(Arrays.toString(bundle.getIntegerArrayList(key).toArray())) .append("\n"); } else if (bundle.get(key) instanceof Parcelable) { sb.append(key).append(":").append(bundle.getParcelable(key).toString()).append("\n"); } else { sb.append(key).append(":").append(bundle.getString(key)).append("\n"); } } } return sb.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()); }//from w w w . ja v a 2 s . c o m return buffer.toString(); }
From source file:Main.java
public static void byteToBit(byte[] bytes, StringBuilder sb) { for (int i = 0; i < Byte.SIZE * bytes.length; i++) sb.append((bytes[i / Byte.SIZE] << i % Byte.SIZE & 0x80) == 0 ? '0' : '1'); }
From source file:Main.java
public static String joinArray(int[] arr, String seperator) { StringBuilder sb = new StringBuilder(); for (Integer i : arr) { sb.append(i).append(seperator); }/*from w w w. j a va 2 s. c o m*/ if (sb.length() > 0) { return sb.subSequence(0, sb.length() - seperator.length()).toString(); } return sb.toString(); }
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]); for (int i = 1; i < array.length; i++) { sb.append(delimiter);/*from w ww . j a va 2 s .c om*/ sb.append(array[i]); } } return sb.toString(); }
From source file:Util.java
/** * @return a String representation of the given object array. * The strings are obtained by calling toString() on the * underlying objects./* w w w . ja v a2 s . co m*/ */ public static String toString(Object[] obj) { if (obj == null) return "NULL"; StringBuilder tmp = new StringBuilder(); tmp.append("["); for (int i = 0; i < obj.length; i++) { tmp.append(obj[i].toString()); if (i != obj.length - 1) { tmp.append(","); } } tmp.append("]"); return tmp.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); }//from ww w. ja v a2 s . c om if (result.length() > 0) { result.delete(0, glue.length()); } return result.toString(); }
From source file:Main.java
/** * Append a start tag to the string buffer. * //from ww w .java 2s .co m * @param output * StringBuilder of the output. * @param propertyName */ public static void appendStartNode(StringBuilder output, String propertyName) { output.append(START_BRACKET); output.append(getCleanPropertyName(propertyName)); output.append(END_BRACKET); }
From source file:Main.java
private static void appendXX(int i, StringBuilder toAppendTo) { if (i < 10) toAppendTo.append('0'); toAppendTo.append(i);/*w w w . j a v a2 s . co m*/ }