List of usage examples for java.lang StringBuilder length
int length();
From source file:Main.java
public static String getCommaSeparatedStringFromArray(ArrayList list) { StringBuilder result = new StringBuilder(); for (int i = 0; i < list.size(); i++) { result.append(list.get(i));/*from w w w.j a va 2 s . c o m*/ result.append(","); } return result.length() > 0 ? result.substring(0, result.length() - 1) : ""; }
From source file:com.tamingtext.tagging.LuceneTagExtractor.java
public static void emitTagDoc(Term term, PrintWriter pw, StringBuilder b) { if (b.length() < 100) { return;/* w w w. j av a2 s . c om*/ } pw.printf("%s\t%s\n", term.text(), b); }
From source file:Main.java
public static String arrayToString(String message, ArrayList<Integer> arr) { StringBuilder resString = new StringBuilder(); resString.append(message);//ww w . j a v a2 s . c o m for (int i : arr) { resString.append(i + 1).append(", "); } resString.delete(resString.length() - 2, resString.length()); return resString.toString(); }
From source file:ca.travelagency.utils.StringUtils.java
public static String format(String... sources) { Validate.notNull(sources);//from w w w. j ava2s . co m StringBuilder stringBuilder = new StringBuilder(); for (String source : sources) { if (StringUtils.isNotBlank(source)) { if (stringBuilder.length() > 0) { stringBuilder.append(SEPERATOR); } stringBuilder.append(source); } } return stringBuilder.toString(); }
From source file:edu.rit.flick.genetics.util.HexPrinter.java
public static String intToBinaryString(final int i) { final StringBuilder str = new StringBuilder( org.apache.commons.lang.StringUtils.leftPad(Integer.toBinaryString(i), 16, '0')); for (int idx = str.length() - 4; idx > 0; idx -= 4) str.insert(idx, "_"); return str.toString(); }
From source file:com.netflix.astyanax.util.StringUtils.java
/** * Convert a string from "_" delimited to lower camel case * /* w ww . j a v a 2s . co m*/ * @param s * @return */ public static String toCamelCase(String s) { String[] parts = s.split("_"); StringBuilder sb = new StringBuilder(); for (String part : parts) { if (sb.length() == 0) sb.append(part.toLowerCase()); else sb.append(toProperCase(part)); } return sb.toString(); }
From source file:Main.java
public static String join(Iterable<?> elements, String separator) { if (elements == null) return ""; StringBuilder buf = new StringBuilder(); if (separator == null) separator = " "; for (Object o : elements) { if (buf.length() > 0) buf.append(separator);/*from w w w . ja v a2 s.c o m*/ buf.append(o); } return buf.toString(); }
From source file:Main.java
public static String join(Collection<? extends Object> list, String separator) { StringBuilder sb = new StringBuilder(); for (Object o : list) { sb.append(o.toString());/* ww w. ja va2 s . c o m*/ sb.append(separator); } if (sb.length() > 0 && separator.length() > 0) { sb.delete(sb.length() - separator.length(), sb.length()); } return sb.toString(); }
From source file:Main.java
public static String toString(Collection<String> c) { StringBuilder sb = new StringBuilder(); for (String s : c) { sb.append(s).append(","); }/*from w w w. j a v a 2 s .c o m*/ if (sb.toString().endsWith(",")) { return sb.substring(0, sb.length() - 1); } else { return sb.toString(); } }
From source file:com.example.admin.processingboilerplate.JsonIO.java
public static JSONObject loadJson(String url) { StringBuilder sb = loadString(url); if (sb == null || sb.length() == 0) return new JSONObject(); JSONObject json = null;//from ww w.j a v a2 s. co m try { json = new JSONObject(sb.toString()); } catch (JSONException e) { Log.e("loadJson", e.getMessage(), e); e.printStackTrace(); return new JSONObject(); } return json; }