List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static SpannableStringBuilder getFrontTextStyle(String frontText, String afterText, int frontColor, int frontTextSize) { StringBuilder sb = new StringBuilder(); sb.append("/").append(afterText); int len = sb.length(); sb.insert(0, frontText);/* w ww. ja va 2s .c om*/ SpannableStringBuilder style = new SpannableStringBuilder(sb); style.setSpan(new ForegroundColorSpan(frontColor), 0, sb.length() - len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); style.setSpan(new AbsoluteSizeSpan(frontTextSize), 0, sb.length() - len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return style; }
From source file:Main.java
public static String getSysDateTimeMillis() { String str = new Timestamp(System.currentTimeMillis()).toString(); if (str.length() >= 23) { return str.substring(0, 23); } else {// w w w. j a v a2 s . c o m StringBuilder sb = new StringBuilder(); sb.append(str); for (int i = 0; i < 23 - str.length(); i++) { sb.append("0"); } return sb.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 va2 s. c om*/ builder.append(']'); return builder.toString(); }
From source file:Main.java
/** * Join an array of {@link String} objects with a {@link String} separator. * * @param strings the array of {@link String} objects to be joined * @param separator the {@link String} object used to delimit the {@code strings} * @return the array of {@code strings} delimited by the {@code separator} * @since 0.5.0//ww w.java2 s .c o m */ public static String join(String[] strings, String separator) { if (strings.length == 0) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(strings[0]); for (int i = 1; i < strings.length; i++) { sb.append(separator); sb.append(strings[i]); } return sb.toString(); }
From source file:Main.java
public static String getPublicDataFolder() { StringBuilder publicFolder = new StringBuilder(); publicFolder.append(Environment.getExternalStorageDirectory()).append(DIRECTORY_NAME); File new_dir = new File(publicFolder.toString()); if (!new_dir.exists()) { new_dir.mkdirs(); }// w w w .jav a 2 s . c o m return publicFolder.toString(); }
From source file:Main.java
public static String fourCCToString(int fourCC) { StringBuilder sb = new StringBuilder(); sb.append('\''); sb.append((fourCC & 0xFF000000) >> 24); sb.append((fourCC & 0x00FF0000) >> 16); sb.append((fourCC & 0x0000FF00) >> 8); sb.append((fourCC & 0x000000FF)); sb.append('\''); return sb.toString(); }
From source file:com.taobao.tddl.common.DynamicLogTest.java
private static String getSpringXmlString(String key, String script) { StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"gb2312\"?>"); sb.append("<!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\""); sb.append(" \"http://www.springframework.org/dtd/spring-beans.dtd\">"); sb.append("<beans>"); sb.append(" <bean id=\"test\" class=\"java.lang.String\">"); sb.append(" <constructor-arg><value>").append(script).append("</value></constructor-arg>"); sb.append(" </bean>"); sb.append("</beans>"); return sb.toString(); }
From source file:Main.java
public static String hashMapToString(Map<? extends Object, ? extends Object> map) { Set<?> entrySet = map.entrySet(); Iterator<?> it = entrySet.iterator(); Map.Entry<? extends Object, ? extends Object> entry = null; StringBuilder strbldr = new StringBuilder(); strbldr.append("{ "); while (it.hasNext()) { entry = (Entry<? extends Object, ? extends Object>) it.next(); strbldr.append(entry.getKey() + ":" + entry.getValue() + ", "); }/*w w w. ja v a 2 s. co m*/ return new StringBuilder(strbldr.substring(0, strbldr.length() - 2)).append(" }").toString(); }
From source file:Main.java
/** * @param newPassword// ww w . j ava2 s . c o m * @return */ public static String padPasswordWithRandomStringData(final String newPassword) { int lCopy = MAX_PWD_LENGTH - 10 - newPassword.length(); StringBuilder pwdBuf = new StringBuilder(); pwdBuf.append(newPassword); if (lCopy > 15) { pwdBuf.append(RAND_STRING.substring(0, lCopy)); } String randPaddedNewPassword = pwdBuf.toString(); return randPaddedNewPassword; }
From source file:Main.java
public static String componentsJoinedByString(List<String> list, String separator) { StringBuilder sb = new StringBuilder(); sb.append(list.get(0)); int length = list.size(); for (int i = 1; i < length; i++) { sb.append(separator).append(list.get(i)); }//from w w w . j a v a2s . co m return sb.toString(); }