List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static String generateBasicAuthToken(String name, String secret) { StringBuilder sb = new StringBuilder(); sb.append(name).append(":").append(secret); try {/*from w w w .jav a2 s . c o m*/ return AUTH_PREFIX_BASIC + Base64.encodeToString(sb.toString().getBytes("UTF-8"), Base64.URL_SAFE | Base64.NO_WRAP); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Helper method to build a field String for creating the table in the format (field1, field2, * ...)//from ww w . java 2 s. c om * * @param fields * @return String in the format (field1, field2, ...) */ private static String toSQLFields(List<String> fields) { StringBuilder s = new StringBuilder(); s.append("("); for (String field : fields) { s.append(field); s.append(","); } s.replace(s.length() - 1, s.length(), ""); s.append(")"); return s.toString(); }
From source file:Main.java
public static String elementToString(Element e) { StringBuilder buf = new StringBuilder(); buf.append(e.getTagName()).append("{"); for (int i = 0; i < e.getAttributes().getLength(); i++) { if (i > 0) { buf.append(", "); }/*from w w w .j a v a2 s . co m*/ Node n = e.getAttributes().item(i); buf.append(attributeName((Attr) n)).append("=").append(n.getNodeValue()); } buf.append("}"); return buf.toString(); }
From source file:Main.java
private static void writeHexByte(StringBuilder sb, int b) { if (b < 0x10) { sb.append('0'); }/*from w ww.j av a 2 s.c o m*/ sb.append(Integer.toHexString(b).toUpperCase()); }
From source file:Main.java
public static void buildShortClassTag(Object cls, StringBuilder out) { if (cls == null) { out.append("null"); return;//from ww w .j a va 2 s. co m } String simpleName = cls.getClass().getSimpleName(); if (simpleName == null || simpleName.length() <= 0) { simpleName = cls.getClass().getName(); int end = simpleName.lastIndexOf(46); if (end > 0) { simpleName = simpleName.substring(end + 1); } } out.append(simpleName); out.append('{'); out.append(Integer.toHexString(System.identityHashCode(cls))); }
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
/** * devuelve el texto enmarcado en una etiqueta. Se supone que la etiqueta exite y tiene valor. Este método funciona correctamente en el caso de que la etiqueta no tenga * multiplicidad. En el caso de que tuviera multiplicidad devolvería únicamente el prime contenido que se encuentre. * @param etiqueta etiqueta de la que queremos extraer su texto * @param documento: documento o subdocumento donde esta definida la etiqueta de la cual queremos extraer su texto * @return String Contenido de la etiqueta. En el caso de que la etiqueta no existiera devuelve <code>null</code> *//*w w w . j av a 2 s . c om*/ public static String dameTextoDeLaEtiquetaSinComprobaciones(String etiqueta, String documento) { StringBuilder sb = new StringBuilder("<"); sb.append(etiqueta).append(">"); int posEtiquetaApertura = documento.indexOf(sb.toString()); sb = new StringBuilder("</"); sb.append(etiqueta).append(">"); int posEtiquetaCierre = documento.indexOf(sb.toString()); return documento.substring(posEtiquetaApertura + etiqueta.length() + 2, posEtiquetaCierre); }
From source file:Main.java
public static String print(long... array) { StringBuilder sb = new StringBuilder(); sb.append("["); if (array != null && array.length > 0) for (int i = 0; i < array.length; i++) sb.append(array[i]).append(i == array.length - 1 ? "]" : ", "); else// w ww . j ava 2 s . c o m sb.append("]"); return sb.toString(); }
From source file:Main.java
public static <M extends Object> String print(M... array) { StringBuilder sb = new StringBuilder(); sb.append("["); if (array != null && array.length > 0) for (int i = 0; i < array.length; i++) sb.append(array[i]).append(i == array.length - 1 ? "]" : ", "); else// ww w. j a va 2 s . c o m sb.append("]"); return sb.toString(); }
From source file:Main.java
public static String limitMessage(String str, int limit) { if (str.length() <= limit) { return str; } else {// w w w . j a v a 2 s .c o m StringBuilder sb = new StringBuilder(str.substring(0, limit)); sb.append("..."); return sb.toString(); } }