List of usage examples for java.lang StringBuilder toString
@Override
@HotSpotIntrinsicCandidate
public String toString()
From source file:Main.java
/** * Reverts the specified source string./* w ww. ja v a2 s . co m*/ * * @param from * The source string. * @return The reverted string. */ public static String revert(String from) { if (from == null || from.length() <= 1) return from; final int len = from.length(); final StringBuilder sb = new StringBuilder(len); for (int i = 1; i <= len; i++) { sb.append(from.charAt(len - i)); } return sb.toString(); }
From source file:Main.java
public static String _10_to_62(long number, int length) { Long rest = number;/*from ww w. j a va 2s . c o m*/ Stack<Character> stack = new Stack<Character>(); StringBuilder result = new StringBuilder(0); while (rest != 0) { stack.add(charSet[new Long((rest - (rest / 62) * 62)).intValue()]); rest = rest / 62; } for (; !stack.isEmpty();) { result.append(stack.pop()); } int result_length = result.length(); StringBuilder temp0 = new StringBuilder(); for (int i = 0; i < length - result_length; i++) { temp0.append('0'); } return temp0.toString() + result.toString(); }
From source file:Main.java
public static String getExternalDir() { final StringBuilder sb = new StringBuilder(); sb.append(Environment.getExternalStorageDirectory().getAbsolutePath()); sb.append("/xdrip"); final String dir = sb.toString(); return dir;/*from w w w .j a v a 2 s . c om*/ }
From source file:net.eledge.android.toolkit.db.internal.SQLBuilder.java
public static String findById(Class<?> clazz) { StringBuilder sb = new StringBuilder(findAll(clazz)); sb.append(" WHERE ").append(getWhereIdClause(clazz)); return sb.toString(); }
From source file:Main.java
public static String generateDeviceUUID(Context context) { String serial = android.os.Build.SERIAL; String androidID = Settings.Secure.ANDROID_ID; String deviceUUID = serial + androidID; /*//from ww w . j a va2s . com * SHA-1 */ MessageDigest digest; byte[] result; try { digest = MessageDigest.getInstance("SHA-1"); result = digest.digest(deviceUUID.getBytes("UTF-8")); } catch (Exception e) { e.printStackTrace(); return null; } StringBuilder sb = new StringBuilder(); for (byte b : result) { sb.append(String.format("%02X", b)); } return sb.toString(); }
From source file:Main.java
public static String addStringsWithSpaces(Object... params) { StringBuilder stringBuilder = new StringBuilder(); for (Object s : params) { stringBuilder.append(s);//from ww w .jav a 2s . c o m stringBuilder.append(" "); } return stringBuilder.toString(); }
From source file:Main.java
public static String md5(String input) { try {/*from w ww . ja v a 2s .c o m*/ MessageDigest md = MessageDigest.getInstance("MD5"); byte[] array = md.digest(input.getBytes("UTF-8")); StringBuilder sb = new StringBuilder(); for (byte anArray : array) { sb.append(String.format("%02x", anArray)); } return sb.toString(); } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { return null; } }
From source file:cn.ctyun.amazonaws.util.StringUtils.java
public static String toString(StringBuilder value) { return value.toString(); }
From source file:Main.java
public static String getStringFromInputStream(InputStream in, String encoding) throws IOException { BufferedReader reader = null; if (encoding == null) { reader = new BufferedReader(new InputStreamReader(in)); } else {/* www.j a va 2 s .com*/ reader = new BufferedReader(new InputStreamReader(in, encoding)); } String line = null; StringBuilder responseData = new StringBuilder(); while ((line = reader.readLine()) != null) { responseData.append(line); } return responseData.toString(); }
From source file:Main.java
public static String getDoubleDigit(int number) { StringBuilder builder = new StringBuilder(); if (number >= 0 && number < 10) { builder.append("0"); }/*from w w w.ja v a 2s. c o m*/ builder.append(number).toString(); return builder.toString(); }