List of usage examples for java.lang StringBuffer length
@Override public synchronized int length()
From source file:com.dc.gameserver.extComponents.Kit.ip.Util.java
/** * @param ip//from ww w . ja v a 2 s . c o m * ip? * @return ?ip */ public static String getIpStringFromBytes(byte[] ip) { try { StringBuffer sb = new StringBuffer(); sb.delete(0, sb.length()); sb.append(ip[0] & 0xFF); sb.append('.'); sb.append(ip[1] & 0xFF); sb.append('.'); sb.append(ip[2] & 0xFF); sb.append('.'); sb.append(ip[3] & 0xFF); return sb.toString(); } catch (Exception e) { return ""; } }
From source file:Main.java
public static String byteArrayToHexString(final byte[] b) { if (b == null || b.length == 0) return null; final StringBuffer sb = new StringBuffer(b.length * 3 - 1); for (final byte element : b) { if (sb.length() > 0) sb.append(':'); final int v = element & 0xff; if (v < 16) sb.append('0'); sb.append(Integer.toHexString(v)); }/* w ww . jav a 2 s .c om*/ return sb.toString().toUpperCase(Locale.US); }
From source file:Main.java
static private void parseParam(String src, String field, StringBuffer params, List<String> args) { if ("*".equals(src)) { return;/*ww w.j a v a 2 s . c o m*/ } if (params.length() > 0) { params.append(" AND"); } if (src.indexOf(",") == -1) { params.append(" " + field + "=?"); args.add(src); } else { String[] weekdays = src.split(","); StringBuffer weekdaysParams = new StringBuffer(); for (int i = 0; i < weekdays.length; ++i) { if (i > 0) { weekdaysParams.append(","); } weekdaysParams.append("?"); args.add(weekdays[i]); } params.append(" " + field + " IN (" + weekdaysParams.toString() + ")"); } }
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. ja v a 2 s . com if (sb.charAt(sb.length() - 1) == ',') { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
From source file:Main.java
public static String join(String[] track) { StringBuffer buf = new StringBuffer(11 * track.length); for (String str : track) { if (0 != buf.length()) { buf.append(","); }//from w w w . j av a 2s .c o m buf.append(str); } return buf.toString(); }
From source file:Main.java
public static String join(int[] follows) { StringBuffer buf = new StringBuffer(11 * follows.length); for (int follow : follows) { if (0 != buf.length()) { buf.append(","); }/* ww w . j ava 2s.c o m*/ buf.append(follow); } return buf.toString(); }
From source file:Main.java
public static String join(long[] follows) { StringBuffer buf = new StringBuffer(11 * follows.length); for (long follow : follows) { if (0 != buf.length()) { buf.append(","); }//from ww w . j ava2s .com buf.append(follow); } return buf.toString(); }
From source file:Main.java
public static String listToString(List<String> weeks) { if (weeks == null || weeks.isEmpty()) { return ""; }//from www . j a v a2 s .c o 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
/** * Convert entities to umlaute/*from w w w. j a v a2 s. c o m*/ */ public static String decode(String value) { StringBuffer buffer = new StringBuffer(value); int pos; boolean found; for (int i = 0; i < buffer.length(); i++) { if (buffer.charAt(i) == '_' && buffer.charAt(i + 1) == '_') { pos = i + 2; found = false; while (buffer.charAt(pos) >= '0' && buffer.charAt(pos) <= '9') { found = true; pos++; } if (found == true && pos > i + 2 && buffer.charAt(pos) == ';') { int ent = new Integer(buffer.substring(i + 2, pos)).intValue(); buffer.replace(i, pos + 1, "" + (char) ent); } } } return buffer.toString(); }
From source file:com.hsbc.frc.SevenHero.ClientProxyAuthentication.java
private static boolean isHeaderEnd(StringBuffer sb) { int len = sb.length(); if (len > 2) { if ("\n\n".equals(sb.substring(len - 2))) { return true; }//from w ww. ja v a2 s .c om } if (len > 4) { if ("\r\n\r\n".equals(sb.substring(len - 4))) { return true; } } return false; }