List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
private static String getTempLocation() { String tmpdir = System.getProperty("java.io.tmpdir"); StringBuilder sb = new StringBuilder(); sb.append(tmpdir); if (!tmpdir.endsWith(File.separator)) sb.append(File.separator); sb.append("TempAzure"); sb.append(File.separator);/*from w w w . ja va2 s . c om*/ return sb.toString(); }
From source file:Main.java
public static String longListToString(List<Long> list) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("["); for (int valuesIndex = 0; valuesIndex < list.size(); valuesIndex++) { long value = list.get(valuesIndex); stringBuilder.append("0x"); stringBuilder.append(Long.toHexString(value).toUpperCase()); if (valuesIndex != list.size() - 1) { stringBuilder.append(", "); }//from w w w .java 2 s . c om } stringBuilder.append("]"); return stringBuilder.toString(); }
From source file:Main.java
public static String buildHtmlForIt(String content, boolean isNightMode) { StringBuilder modifiedHtml = new StringBuilder(); modifiedHtml.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head>" + "<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=utf-8\"/>" + "<meta http-equiv=\"Cache-control\" content=\"public\" />" + "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0\" />" + "<link rel=\"stylesheet\" href=\"file:///android_asset/news.css\" type=\"text/css\">" + "<script src=\"file:///android_asset/jquery.min.js\"></script>" + "<script src=\"file:///android_asset/info.js\"></script>"); modifiedHtml.append("<body "); if (isNightMode) { modifiedHtml.append("class=\'night\'"); }/*from ww w . j ava 2 s . co m*/ modifiedHtml.append(">"); modifiedHtml.append(content); modifiedHtml.append("</body></html>"); return modifiedHtml.toString(); }
From source file:Main.java
public static String join(Collection<String> c, String sep) { StringBuilder sb = new StringBuilder(); for (String str : c) { sb.append(str + sep); }/*from w ww .j a va2s .com*/ return sb.toString(); }
From source file:Main.java
private static String wrap(String s, float width, Paint p) { String[] str = s.split("\\s"); //regex StringBuilder smb = new StringBuilder(); //save memory smb.append(SYSTEM_NEWLINE); for (int x = 0; x < str.length; x++) { float length = p.measureText(str[x]); String[] pieces = smb.toString().split(SYSTEM_NEWLINE); try {// w ww . j a v a2 s . c o m if (p.measureText(pieces[pieces.length - 1]) + length > width) smb.append(SYSTEM_NEWLINE); } catch (Exception e) { } smb.append(str[x] + " "); } return smb.toString().replaceFirst(SYSTEM_NEWLINE, ""); }
From source file:Main.java
public static String print(int... array) { StringBuilder sb = new StringBuilder(); sb.append("["); if (array != null && array.length > 0) for (int i = 0; i < array.length; i++) sb.append(array[i]).append(i == array.length - 1 ? "]" : ", "); else {//w ww . j a v a2s.c o m if (array != null && array.length == 0) sb.append("empty"); sb.append("]"); } return sb.toString(); }
From source file:Main.java
/** * Returns a string containing len times comma separated ? placeholders. * i.e. ?, ?, ?, ? for len = 4//w ww . ja va 2s . com * * @param len * @return */ public static String makePlaceholders(int len) { if (len < 1) { // It will lead to an invalid query anyway .. throw new RuntimeException("No placeholders"); } else { StringBuilder sb = new StringBuilder(len * 2 - 1); sb.append("?"); for (int i = 1; i < len; i++) { sb.append(",?"); } return sb.toString(); } }
From source file:Main.java
static public String assemblyUrlByCommon(String url, Map<String, String> params) { if (params == null && params.size() == 0) { return url; } else {/* w w w . j av a 2s. co m*/ StringBuilder sb = new StringBuilder(url); sb.append("?"); Set<String> keys = params.keySet(); int i = 0; for (String key : keys) { String value = params.get(key); sb.append(key).append("=").append(value); if (i != keys.size() - 1) { sb.append("&"); } i++; } return sb.toString(); } }
From source file:Main.java
public static String generateKey(String key, int position) { StringBuilder sb = new StringBuilder(); sb.append(key); sb.append(":"); sb.append(position);// www. j av a2 s . com return sb.toString(); }
From source file:Main.java
private static String formatAddress(byte[] addr) { StringBuilder buf = new StringBuilder(24); for (byte b : addr) { buf.append(String.format("%02x:", b & 0xff)); }/*from w w w . jav a 2 s. c om*/ return buf.substring(0, buf.length() - 1); }