List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
private static String capitalize(String original) { if (original.isEmpty()) { return original; }/*from w w w . j a v a 2s . c om*/ StringBuilder sb = new StringBuilder(); sb.append(original.substring(0, 1).toUpperCase()); sb.append(original.substring(1)); return sb.toString(); }
From source file:Main.java
/** * Generates a Repox Table Name from the collection identifier * //from www. ja va 2 s .c o m * @param menmonic * @return the Repox tablename */ public static String generateRepoxTableName(String menmonic) { StringBuilder sb = new StringBuilder(); sb.append("repox_"); sb.append(menmonic); sb.append("_record"); return sb.toString(); }
From source file:Main.java
private static SecretKeySpec generateAESKey(String password) { byte[] data = null; StringBuilder sb = new StringBuilder(); sb.append(password); while (sb.length() < 16) sb.append("0"); if (sb.length() > 16) sb.setLength(16);//from w w w .j a va 2s . c o m try { data = sb.toString().getBytes("UTF-8"); return new SecretKeySpec(data, "AES"); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static StringBuilder byteToHex(StringBuilder sb, int b) { b &= 0xFF;//from w ww. jav a2s .c o m sb.append("0123456789ABCDEF".charAt(b >> 4)); sb.append("0123456789ABCDEF".charAt(b & 0xF)); return sb; }
From source file:Main.java
public static String getDistanceString(List<String> list) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("&origin=").append(list.get(0)); stringBuilder.append("&destination=").append(list.get(list.size() - 1)); stringBuilder.append("&waypoints="); for (int i = 1; i < list.size() - 1; i++) { stringBuilder.append(list.get(i)); if (i != list.size() - 2) stringBuilder.append("|"); }//from w w w .ja va 2s .c o m return stringBuilder.toString(); }
From source file:Main.java
/** * Join an array of strings with the given separator. * <p>//from w w w. j a v a 2 s. c o m * Note: This might be replaced by utility method from commons-lang or guava someday * if one of those libraries is added as dependency. * </p> * * @param array The array of strings * @param separator The separator * @return the resulting string */ public static String join(String[] array, String separator) { int len = array.length; if (len == 0) return ""; StringBuilder out = new StringBuilder(); out.append(array[0]); for (int i = 1; i < len; i++) { out.append(separator).append(array[i]); } return out.toString(); }
From source file:Main.java
public static String revStr(String s) { StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) { sb.append(s.charAt(i)); }//from www . j a v a 2 s . co m return sb.toString(); }
From source file:Main.java
private static String createCommand(String app, String email, String secret) { StringBuilder builder = new StringBuilder(); builder.append(app); builder.append(" otpauth://totp/"); builder.append(email);/*from w ww . j a v a2s. co m*/ builder.append("?secret="); builder.append(secret); return builder.toString(); }
From source file:Main.java
/** * Creates a human readable representation of an array of bytes. * * @param bytes The bytes.//from w ww .j a va 2 s. c om * @return An string representation of the bytes. */ public static String toString(final byte[] bytes) { final StringBuilder builder = new StringBuilder(); builder.append("{ "); for (final byte b : bytes) { builder.append(String.format("%02X ", (byte) (0xFF & b))); } builder.append("}"); return builder.toString(); }
From source file:Main.java
public static String long2String(long l, int minDigits) { StringBuilder s = new StringBuilder(minDigits); s.append(Long.toString(l)); while (s.length() < minDigits) { s.insert(0, "0"); }/*from w w w .j a va 2 s. c o m*/ return s.toString(); }