List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:com.mmj.app.common.util.SerialNumGenerator.java
private static String getSuffix(Long id) { Long num = 1l;/*ww w . ja va 2 s . com*/ if (id != null) { num = id % 100000;// id?? } Random random = new Random(); StringBuffer suffixBuffer = new StringBuffer(); suffixBuffer.append(String.valueOf(num)).append(random.nextInt(1000)); return StringUtils.leftPad(suffixBuffer.toString(), 8, '0'); }
From source file:Main.java
public static String getElementStartTagWithAttributes(String elementName, Map<String, String> attributes) { if (notEmptyStr(elementName) && attributes != null) { StringBuffer buffer = new StringBuffer(); buffer.append(TAG_START).append(elementName); for (String key : attributes.keySet()) { String value = attributes.get(key); if (value == null) { value = ""; }//from w ww . j av a2 s. c om buffer.append(" ").append(key).append("=").append("\"").append(value).append("\""); } return buffer.append(TAG_END).toString(); } return null; }
From source file:Main.java
public static void content(StringBuffer buf, String content) { if (content != null) { buf.append("<![CDATA[" + content + "]]>"); }/* w ww.j av a 2s .com*/ }
From source file:Main.java
public static String toString(Object[] arr) { if (arr == null) return "null"; ///*from ww w .ja v a 2 s. c om*/ StringBuffer sb = new StringBuffer(); int i = 1; sb.append("(size=" + arr.length + ")"); for (Object o : arr) { sb.append("[" + i + ":" + o + "]"); i++; } return sb.toString(); }
From source file:Main.java
static void appendSubstring(StringBuffer sb, String si, int i0, int i1) { if (i0 + 10 < i1) { sb.append(si.substring(i0, i1)); } else {/*from ww w .ja v a2 s. com*/ for (int i = i0; i < i1; i++) { sb.append(si.charAt(i)); } } }
From source file:Main.java
private static void printName(String prefix, String uri, String localName, StringBuffer b) { if (uri != null && !("".equals(uri))) b.append("['" + uri + "']:"); if (prefix != null && !("".equals(prefix))) b.append(prefix + ":"); if (localName != null) b.append(localName);/*from ww w . j ava2 s. com*/ }
From source file:Main.java
public static String printBytes(byte[] data) { StringBuffer sb = new StringBuffer(); sb.append("["); for (int i = 0; i < data.length; i++) { String hex = Integer.toHexString(data[i]); if (hex.length() == 1) hex = "0" + hex; else//w w w . j av a 2s . c o m hex = hex.substring(hex.length() - 2); sb.append(hex); if (i < data.length - 1) { if ((i + 1) % 30 == 0) sb.append("\n "); else if ((i + 1) % 10 == 0) sb.append(" "); else sb.append(" "); } } sb.append("]"); return sb.toString(); }
From source file:Main.java
/** * Convert the list of Integers into a comma separated * string so that it's easy to load back in. * @param list// w w w .j av a 2 s.co m * @return */ public static String toString(List<?> list) { StringBuffer buf = new StringBuffer(); for (Object o : list) buf.append(o + ","); buf.deleteCharAt(buf.length() - 1); return buf.toString(); }
From source file:AlignX.java
private static String makeLabel(String s, int length) { StringBuffer buff = new StringBuffer(length); for (int i = 0; i < length; i++) { buff.append(s); }//from w ww. java 2 s . co m return buff.toString(); }
From source file:Main.java
public static String toHexString(byte b) { StringBuffer result = new StringBuffer(3); result.append(Integer.toString((b & 0xF0) >> 4, 16)); result.append(Integer.toString(b & 0x0F, 16)); return result.toString(); }