List of usage examples for java.lang StringBuffer StringBuffer
public StringBuffer(CharSequence seq)
From source file:Main.java
private static String toHexString(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16)); sb.append(Character.forDigit(bytes[i] & 0X0F, 16)); }/*from w w w . ja v a 2s . c om*/ return sb.toString(); }
From source file:Main.java
public static String filterInvalid(String xml) { StringBuffer sb = new StringBuffer(xml); for (int i = 0; i < sb.length(); i++) { int c = sb.charAt(i); if (c < 0x20 && c != 0x09/*\t*/ && c != 0x0A/*\n*/ && c != 0x0D/*\r*/) { sb.delete(i, i + 1);// ww w . ja v a 2 s .co m } } return sb.toString(); }
From source file:Main.java
public static String bcd2StrIn(byte[] bytes) { StringBuffer temp = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { temp.append((byte) ((bytes[i] & 0xf0) >>> 4)); temp.append((byte) (bytes[i] & 0x0f)); }//from w w w .j a v a 2 s .c om return temp.toString().substring(0, 1).equalsIgnoreCase("0") ? temp.toString().substring(1) : temp.toString(); }
From source file:Main.java
public static String toHex(byte[] bytes) { StringBuffer buf = new StringBuffer(""); String tmp = null;/*w w w .j a va 2 s . co m*/ for (int i = 0; i < bytes.length; i++) { tmp = (Integer.toHexString(bytes[i] & 0xFF)); if (tmp.length() == 1) { buf.append("0"); } buf.append(tmp); } return buf.toString(); }
From source file:Main.java
public static String Bcd2Str_0(byte[] bytes) { StringBuffer temp = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { temp.append((byte) ((bytes[i] & 0xf0) >>> 4)); temp.append((byte) (bytes[i] & 0x0f)); }/*from www . j a v a 2 s . c o m*/ return temp.toString().substring(0, temp.toString().length() - 1); }
From source file:Main.java
public static String convertToCommaDelimited(String[] list) { StringBuffer ret = new StringBuffer(""); for (int i = 0; list != null && i < list.length; i++) { ret.append(list[i]);//www .j a v a 2 s .c o m if (i < list.length - 1) { ret.append(','); } } return ret.toString(); }
From source file:Main.java
public static String toHexString(byte[] input) { StringBuffer sb = new StringBuffer(input.length); String sTemp;//from w ww . ja v a 2s . co m for (int i = 0; i < input.length; i++) { sTemp = Integer.toHexString(0xFF & input[i]); if (sTemp.length() < 2) sb.append(0); sb.append(sTemp.toUpperCase()); } return sb.toString(); }
From source file:Main.java
private static String getScalePattern(int scale) { StringBuffer sb = new StringBuffer("#0."); if (scale <= 0) { sb = new StringBuffer("#"); }//w ww .ja v a2 s . com for (int i = 0; i < scale; ++i) { sb.append("0"); } return sb.toString(); }
From source file:Main.java
private static String byte2hexString(byte buf[]) { StringBuffer strbuf = new StringBuffer(buf.length * 2); int i;/*from ww w . j a v a2 s . c o m*/ for (i = 0; i < buf.length; i++) { strbuf.append(Integer.toString((buf[i] >> 4) & 0xf, 16) + Integer.toString(buf[i] & 0xf, 16)); } return strbuf.toString(); }
From source file:Main.java
private static String bytes2hex(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; ++i) { int v = bytes[i] & 255; if (v < 16) { sb.append('0'); }/*from w w w . j a va 2 s. com*/ sb.append(Integer.toHexString(v)); } return sb.toString(); }