List of usage examples for java.lang StringBuilder StringBuilder
@HotSpotIntrinsicCandidate
public StringBuilder()
From source file:Main.java
public static String getHexString2(final byte[] b) { StringBuilder result = new StringBuilder(); for (byte element : b) { int asInt = unsignedByteToInt(element); result.append(Integer.toHexString(asInt)); }//ww w.j a va 2 s .co m return result.toString(); }
From source file:Main.java
public static String getPhoneInfo() { StringBuilder phoneInfoSB = new StringBuilder(); phoneInfoSB.append("Product: ").append(android.os.Build.PRODUCT); phoneInfoSB.append(", CPU_ABI: ").append(android.os.Build.CPU_ABI); phoneInfoSB.append(", TAGS: ").append(android.os.Build.TAGS); phoneInfoSB.append(", VERSION_CODES.BASE: ").append(android.os.Build.VERSION_CODES.BASE); phoneInfoSB.append(", MODEL: ").append(android.os.Build.MODEL); phoneInfoSB.append(", SDK: ").append(android.os.Build.VERSION.SDK_INT); phoneInfoSB.append(", VERSION.RELEASE: ").append(android.os.Build.VERSION.RELEASE); phoneInfoSB.append(", DEVICE: ").append(android.os.Build.DEVICE); phoneInfoSB.append(", DISPLAY: ").append(android.os.Build.DISPLAY); phoneInfoSB.append(", BRAND: ").append(android.os.Build.BRAND); phoneInfoSB.append(", BOARD: ").append(android.os.Build.BOARD); phoneInfoSB.append(", FINGERPRINT: ").append(android.os.Build.FINGERPRINT); phoneInfoSB.append(", ID: ").append(android.os.Build.ID); phoneInfoSB.append(", MANUFACTURER: ").append(android.os.Build.MANUFACTURER); phoneInfoSB.append(", USER: ").append(android.os.Build.USER); return phoneInfoSB.toString(); }
From source file:Main.java
private static String buildMd5String(byte[] md5Bytes) { StringBuilder md5String = new StringBuilder(); for (byte b : md5Bytes) { int num = b >= 0 ? b : b + 256; if (num < 16) { md5String.append("0"); }//from www . ja va2 s. c o m md5String.append(Integer.toHexString(num)); } return md5String.toString(); }
From source file:Main.java
public static String addQuote(String value) { StringBuilder str = new StringBuilder(); if (null == value) { return null; }//from w w w . j a va 2s .c o m str.append("\'").append(value).append("\'"); return str.toString(); }
From source file:Main.java
public static String bytesToBitSetString(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { int b = bytes[i]; for (int j = 0; j < 8; j++) { if ((b & (1 << j)) == (1 << j)) { sb.append('1'); } else { sb.append('0'); }/*from ww w .j ava 2s. c o m*/ } } return sb.toString(); }
From source file:Main.java
public static String bytesToHexWithSpaces(byte[] bytes) { StringBuilder newString = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String byteHex = String.format("0x%02X", (byte) bytes[i]); newString.append(byteHex).append(" "); }/*from www. j a v a 2s . c o m*/ return newString.toString().trim(); }
From source file:Main.java
public static String bytesToHexWithSpaces(byte[] bytes) { StringBuilder newString = new StringBuilder(); for (int i = 0; i < bytes.length; i++) { String byteHex = String.format("%02X", (byte) bytes[i]); newString.append(byteHex).append(" "); }//w w w . j ava2s . com return newString.toString().trim(); }
From source file:Main.java
public static String join(String[] strs, String split) { StringBuilder sb = new StringBuilder(); if (strs == null || split == null || strs.length <= 0) { return null; }// ww w.j av a 2 s . c om for (int i = 0, count = strs.length; i < count; i++) { sb.append(strs[i]); if (i != (count - 1)) { sb.append(split); } } return sb.toString(); }
From source file:Main.java
public static String fixApplicationId(final String appId) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < appId.length(); i++) { final char ch = appId.charAt(i); if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '9' || ch == '-' || ch == '.') { builder.append(ch);//from w ww . j a va 2 s . c o m } } return builder.toString(); }
From source file:Main.java
public static String computePhraseShape(String x) { StringBuilder buf = new StringBuilder(); char lastc = 0; for (int i = 0; i < x.length(); i++) { char c = x.charAt(i); if (Character.isDigit(c)) c = '0'; else if (Character.isLetter(c)) c = Character.isLowerCase(c) ? 'a' : 'A'; else if (Character.isWhitespace(c) || Character.isSpaceChar(c)) c = ' '; if (c != lastc) buf.append(c);//from www .j av a 2 s . co m lastc = c; } return buf.toString(); }