List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:Main.java
public static String byte2Hex(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(HEX_ARRAY[(bytes[i] & 0xf0) >>> 4]); sb.append(HEX_ARRAY[bytes[i] & 0x0f]); }/*from w ww. ja v a2 s.c om*/ return sb.toString(); }
From source file:Main.java
public static String MD5(String md5) { try {/*from w w w . ja v a2 s .co m*/ java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); byte[] array; try { array = md.digest(md5.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); array = md.digest(md5.getBytes()); } StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (java.security.NoSuchAlgorithmException e) { } return null; }
From source file:com.aw.swing.mvp.ui.common.LabelResolver.java
/** * lblF1gd lblF1gd1 lblF1gd2// w w w. j a va 2 s .c om * * @param keyCode * @param gridIndex * @return */ public static String getLabelNameForAction(int keyCode, int gridIndex) { StringBuffer sb = new StringBuffer(); sb.append(getLabelNameForAction(keyCode)); sb.append("gd"); if (gridIndex != 0) { sb.append(gridIndex); } return sb.toString(); }
From source file:Main.java
private static String join(String delimiter, String[] source) { StringBuffer buffer = new StringBuffer(); int i = 0;//www. j a v a 2 s. c o m while (i < source.length) { buffer.append(source[i]); if (i < source.length - 1) { buffer.append(delimiter); } i++; } return buffer.toString(); }
From source file:Main.java
public static String join(Object... objs) { if (objs == null) return ""; StringBuffer s = new StringBuffer(); for (int i = 0, n = objs.length; i < n; i++) { s.append(objs[i]); if (i != n - 1) s.append(","); }//from w ww . j a v a 2 s . co m return s.toString(); }
From source file:Main.java
public static String join(int[] objs) { if (objs == null) return ""; StringBuffer s = new StringBuffer(); for (int i = 0, n = objs.length; i < n; i++) { s.append(objs[i]); if (i != n - 1) s.append(","); }//w ww.j ava 2 s. c o m return s.toString(); }
From source file:Main.java
public static String join(long[] objs) { if (objs == null) return ""; StringBuffer s = new StringBuffer(); for (int i = 0, n = objs.length; i < n; i++) { s.append(objs[i]); if (i != n - 1) s.append(","); }/*from w w w.j a v a2 s . com*/ return s.toString(); }
From source file:Main.java
/** * Takes String[] of tokens, and String delimiter as input and returns * joined String/*from ww w . j a v a2s . c om*/ * * @param sourceArray * , input tokens in String array * @param delimiter * , delimiter to join on * @return String , string of tokens joined by delimiter */ public static String joinString(String[] sourceArray, String delimiter) { if (sourceArray == null || delimiter == null) { return ""; } StringBuffer sb = new StringBuffer(); for (int i = 0; i < sourceArray.length - 1; i++) { sb.append(sourceArray[i]).append(delimiter); } sb.append(sourceArray[sourceArray.length - 1]); return sb.toString(); }
From source file:Main.java
public static String byteToPdu(int b) { StringBuffer sb = new StringBuffer(); String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) { sb.append("0"); }/* w ww.j av a2 s . c o m*/ sb.append(s); return sb.toString().toUpperCase(); }
From source file:Main.java
private static void appendHexPair(byte bt, StringBuffer stringbuffer) { char c0 = hexDigits[(bt & 0xf0) >> 4]; char c1 = hexDigits[bt & 0xf]; stringbuffer.append(c0); stringbuffer.append(c1);//from ww w. j a v a 2 s .c o m }