List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:Main.java
/** * Utility method for building up URL param string. * //from w ww.ja va 2 s . c o m * @param params * @return URL parameter string */ private static String buildParamString(Map<String, String> params) { StringBuffer paramBuf = new StringBuffer(); if (params != null && params.size() > 0) { paramBuf.append('?'); Iterator<Map.Entry<String, String>> iter = params.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, String> param = (Map.Entry<String, String>) iter.next(); paramBuf.append(param.getKey() + "=" + param.getValue()); if (iter.hasNext()) { paramBuf.append('&'); } } } Log.i("PARAM STRING CHECK", paramBuf.toString()); return paramBuf.toString(); }
From source file:Main.java
public static String createXmlResponse(String status, String desription) { StringBuffer response = new StringBuffer( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response><responseCode>"); response.append(status).append("</responseCode><responseInfo>").append(desription) .append("</responseInfo></response>"); return response.toString(); }
From source file:Main.java
private static String getCrashReport(Throwable e, Context application) { StringBuffer body = new StringBuffer(); body.append("Timestamp: " + new Date().toString()); body.append("\n** Crash Report **\n"); try {// www.j a va2s. c o m PackageInfo pi = application.getPackageManager().getPackageInfo(application.getPackageName(), 0); body.append("Package Name: ").append(pi.packageName).append("\n"); body.append("Package Version: ").append(pi.versionCode).append("\n"); body.append("Phone Model: ").append(android.os.Build.MODEL).append("\n"); body.append("Phone Manufacturer: ").append(android.os.Build.MANUFACTURER).append("\n"); body.append("Android Version:").append(android.os.Build.VERSION.RELEASE).append("\n"); } catch (NameNotFoundException e1) { } StringWriter stack = new StringWriter(); PrintWriter writer = new PrintWriter(stack); e.printStackTrace(writer); body.append("\n\nStacktrace:\n\n"); body.append(stack.toString()).append("\n"); if (e.getCause() != null) { Throwable cause = e.getCause(); stack = new StringWriter(); writer = new PrintWriter(stack); cause.printStackTrace(writer); body.append("\n\nCause Stacktrace:\n\n"); body.append(stack.toString()).append("\n"); } body.append("** Crash Report **\n"); return body.toString(); }
From source file:Util.java
/** * Converts a String array to an String, joined by the Seperator * * @param items The String Array to Join * @param seperator The Seperator used to join the String * @return The Joined String//from w w w . ja v a 2 s.c o m */ public static String arrayToString(String[] items, String seperator) { if ((items == null) || (items.length == 0)) { return ""; } else { StringBuffer buffer = new StringBuffer(items[0]); for (int i = 1; i < items.length; i++) { buffer.append(seperator); buffer.append(items[i]); } return buffer.toString(); } }