List of usage examples for java.lang StringBuilder length
int length();
From source file:Main.java
private static String getTwoDigitHexString(int integer) { StringBuilder sb = new StringBuilder(); sb.append(Integer.toHexString(integer)); if (sb.length() < 2) { sb.insert(0, '0'); // pad with leading zero if needed }//from w ww. j a va 2s . c o m return sb.toString(); }
From source file:Main.java
public static String toQuery(Iterable arg) { StringBuilder builder = new StringBuilder(); //noinspection UnusedDeclaration for (Object i : arg) { if (builder.length() > 0) builder.append(","); builder.append("?"); }//from ww w . jav a 2 s . c o m return builder.toString(); }
From source file:com.conwet.xjsp.json.JSONUtil.java
public static void discardSpaces(StringBuilder buffer) { while (buffer.length() > 0 && (isSpace(buffer.charAt(0)) || buffer.charAt(0) == ',')) { buffer.deleteCharAt(0);//from w w w . j a v a 2s. c om } }
From source file:Main.java
public static String parametersToWWWFormURLEncoded(Map<String, String> parameters) throws Exception { StringBuilder s = new StringBuilder(); for (Map.Entry<String, String> parameter : parameters.entrySet()) { if (s.length() > 0) { s.append("&"); }//from w w w . j ava 2s. com s.append(URLEncoder.encode(parameter.getKey(), "UTF-8")); s.append("="); s.append(URLEncoder.encode(parameter.getValue(), "UTF-8")); } return s.toString(); }
From source file:Main.java
public static String joinStrings(List<String> strings, String delimiter, @NonNull StringBuilder builder) { builder.setLength(0);/*w w w.j a v a 2 s . com*/ if (strings != null) for (String str : strings) { if (builder.length() > 0) builder.append(delimiter); builder.append(str); } return builder.toString(); }
From source file:com.jythonui.server.BUtil.java
private static String add(String path, String fName) { StringBuilder bu = new StringBuilder(path); int la = bu.length() - 1; char ch = bu.charAt(la); if (!isFSep(ch)) { return path + File.separator + fName; }/*from ww w.jav a2 s. c o m*/ return path + fName; }
From source file:net.bulletin.pdi.xero.step.support.Helpers.java
/** * <p>If the value is provided then this method will augment the supplied URL by adding on the * query to the URL.</p>// w w w . ja v a2 s . c om */ public static StringBuilder appendUrlQuery(StringBuilder url, String key, String value) { if (null == url || 0 == url.length()) { throw new IllegalArgumentException("the supplied url may not be empty."); } if (StringUtils.isEmpty(key)) { throw new IllegalArgumentException("the supplied query key may not be empty."); } if (StringUtils.isNotBlank(value)) { url.append(-1 == url.indexOf("?") ? '?' : '&'); url.append(key); url.append("="); try { url.append(URLEncoder.encode(value, CharEncoding.UTF_8)); } catch (UnsupportedEncodingException uee) { throw new IllegalStateException("the encoding must be supported; " + CharEncoding.UTF_8); } } return url; }
From source file:Main.java
public static String getDumpObjectArray(Object[] aObjects) { StringBuilder stringBuilder = new StringBuilder(); if (aObjects != null) { for (Object object : aObjects) { if (stringBuilder.length() != 0) { stringBuilder.append(", "); }// ww w . ja v a2 s . co m stringBuilder.append(object); } } return stringBuilder.toString(); }
From source file:Main.java
public static String borraEtiqueta(String tag, String contenido, String documento) { StringBuilder st = new StringBuilder(documento); int posBusquedaInicio = 0; int tamanioDocumento = st.length(); while (posBusquedaInicio < tamanioDocumento) { int posInicio = st.indexOf("<" + tag + ">", posBusquedaInicio); if (posInicio != -1) { String t = "</" + tag + ">"; int posFin = st.indexOf(t, posBusquedaInicio); int longitudTag = t.length(); int posContenido = documento.indexOf(contenido); if (posInicio < posContenido && posContenido < posFin) { st.delete(posInicio, posFin + longitudTag); return st.toString(); }//from ww w. ja v a 2 s .co m posBusquedaInicio = posFin + longitudTag; } else { return documento; } } return documento; }
From source file:Main.java
public static String join(List<String> strs) { StringBuilder buf = new StringBuilder(11 * strs.size()); for (String str : strs) { if (0 != buf.length()) { buf.append(","); }/*from ww w . jav a2 s.co m*/ buf.append(str); } return buf.toString(); }