List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:Main.java
private static String join(int length) { StringBuffer sb = new StringBuffer(1024); for (int i = 0; i < length; i++) { sb.append("?,"); }/*from w w w. j a v a 2s.com*/ if (sb.charAt(sb.length() - 1) == ',') { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
From source file:Main.java
/** * A deliberately very inflexible camel case to underscored converter; it must not convert improper camel case * names to a proper underscored name.//from ww w . j a v a2 s . co m */ public static String camelCaseToUnderscored(String camelCaseName) { int i = 0; while (i < camelCaseName.length() && Character.isLowerCase(camelCaseName.charAt(i))) { i++; } if (i == camelCaseName.length()) { // No conversion needed return camelCaseName; } StringBuffer sb = new StringBuffer(); sb.append(camelCaseName.substring(0, i)); while (i < camelCaseName.length()) { final char c = camelCaseName.charAt(i); if (isUpperUSASCII(c)) { sb.append('_'); sb.append(Character.toLowerCase(c)); } else { sb.append(c); } i++; } return sb.toString(); }
From source file:Main.java
protected static String pad(int cols) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < cols; i++) sb.append(' '); return sb.toString(); }
From source file:Main.java
private static StringBuffer escape(char c, StringBuffer buffer) { String encoded = encodingMap.get(c); return buffer.append(encoded == null ? Character.toString(c) : encoded); }
From source file:Main.java
public static <K, V> String mapToString(Map<K, V> map, String seperator) { StringBuffer sb = new StringBuffer(); for (Entry<K, V> entry : map.entrySet()) { sb.append(entry.getKey() + seperator + entry.getValue() + "\n"); }// w ww .ja v a 2s.c om return sb.toString(); }
From source file:Main.java
public static String asciiToString(byte[] arrayList) { StringBuffer sbu = new StringBuffer(); for (int i = 0; i < arrayList.length; i++) { sbu.append((char) arrayList[i]); }// w ww . java2 s .co m return sbu.toString(); }
From source file:Main.java
public static String listToString(List<String> weeks) { if (weeks == null || weeks.isEmpty()) { return ""; }// w w w .j a va 2 s. co m StringBuffer result = new StringBuffer(); for (String week : weeks) { result.append(week).append(","); } if (result.length() != 0) { result.deleteCharAt(result.length() - 1); } return result.toString(); }
From source file:Main.java
public static String getByteArray(byte[] data) { final StringBuffer sb = new StringBuffer(); for (int i = 0; i < data.length; i++) { sb.append(data[i] + ","); }/*from www. java2 s . c om*/ return sb.toString().substring(0, sb.length() - 1); }
From source file:Main.java
public static String arrayToString(Object[] objs, String separator) { if (objs == null) { return "[null]"; }//from ww w . j a v a2s . c om StringBuffer result = new StringBuffer(); if (objs.length > 0) { result.append(objs[0] != null ? objs[0].toString() : objs[0]); for (int i = 1; i < objs.length; i++) { result.append(separator); result.append(objs[i] != null ? objs[i].toString() : objs[i]); } } return result.toString(); }
From source file:Main.java
/** * converts an array of bytes into a hex string. * /*from ww w . j a v a2 s . c om*/ * @param bytes array of bytes to convert to hex string * @return hex string representation of input array */ public static String bytesToHexString(byte[] bytes) { if (bytes == null) return "null"; StringBuffer sb = new StringBuffer(); for (byte b : bytes) { sb.append(String.format("%02X ", b & 0xFF)); } return sb.toString(); }