List of usage examples for java.lang StringBuilder StringBuilder
public StringBuilder(CharSequence seq)
From source file:Main.java
public static String formatMac(String mac) { StringBuilder sb = new StringBuilder(mac); sb.insert(2, ":"); sb.insert(5, ":"); sb.insert(8, ":"); sb.insert(11, ":"); sb.insert(14, ":"); return sb.toString(); }
From source file:Main.java
public static String repeat(String s, int cnt) { StringBuilder sb = new StringBuilder(s.length() * cnt); for (int i = 0; i < cnt; i++) { sb.append(s);// ww w .jav a 2 s . c o m } return sb.toString(); }
From source file:Main.java
public static String getUserAgent() { StringBuilder model = new StringBuilder(android.os.Build.MODEL); if (model.toString().startsWith("\"")) { model.deleteCharAt(0);//from w w w . j a va2s. c o m } if (model.toString().endsWith("\"")) { model.deleteCharAt(model.length() - 1); } return model.toString(); }
From source file:Main.java
public static String HexEncode(byte[] toencode) { StringBuilder sb = new StringBuilder(toencode.length * 2); for (byte b : toencode) { sb.append(Integer.toHexString((b & 0xf0) >>> 4)); sb.append(Integer.toHexString(b & 0x0f)); }//w w w . j a va 2 s. c o m return sb.toString(); }
From source file:Main.java
public static String i(int[] iArr) { StringBuilder stringBuilder = new StringBuilder(32); stringBuilder.append('('); for (int append : iArr) { stringBuilder.append(append).append(','); }//from www . j a va2s . c o m stringBuilder.setCharAt(stringBuilder.length() - 1, ')'); return stringBuilder.toString(); }
From source file:Main.java
public static String maskString(String s) { StringBuilder stringbuilder = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { stringbuilder.append("*"); }//from w w w .ja va 2s. c om return stringbuilder.toString(); }
From source file:Main.java
public static String encodeHex(byte[] bytes) { StringBuilder hex = new StringBuilder(bytes.length * 2); for (byte aByte : bytes) { if (((int) aByte & 0xff) < 0x10) { hex.append("0"); }/*from w w w . ja va 2s . c o m*/ hex.append(Integer.toString((int) aByte & 0xff, 16)); } return hex.toString(); }
From source file:Main.java
public static String getPid() { StringBuilder pid = new StringBuilder(Build.MANUFACTURER).append(" ").append(Build.MODEL).append(" - ") .append(Build.VERSION.RELEASE); return pid.toString(); }
From source file:Main.java
public static String intToHexString(int a) { StringBuilder stringBuilder = new StringBuilder(""); int v = a & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { stringBuilder.append(0);/*from ww w . ja v a2s. c o m*/ } stringBuilder.append(hv); return stringBuilder.toString(); }
From source file:Main.java
public static String toDisplayString(byte[] bytes) { StringBuilder builder = new StringBuilder(bytes.length); builder.append('['); for (int i = 0; i < bytes.length; i++) { builder.append(bytes[i] + ", "); }//from w w w .j a v a 2 s . c om builder.append(']'); return builder.toString(); }