Example usage for java.lang StringBuffer append

List of usage examples for java.lang StringBuffer append

Introduction

In this page you can find the example usage for java.lang StringBuffer append.

Prototype

@Override
    public synchronized StringBuffer append(double d) 

Source Link

Usage

From source file:Main.java

public static String getNodePath(Node node) {
    StringBuffer sb = new StringBuffer(32);
    while (node != null) {
        sb.append(node.getNodeName());
        sb.append("/");
        node = node.getParentNode();/*from ww w.j av a  2 s. c om*/
    }
    return sb.toString();
}

From source file:Main.java

public static String makeTimeString(long milliSecs) {
    StringBuffer sb = new StringBuffer();
    long m = milliSecs / (60 * 1000);
    sb.append(m < 10 ? "0" + m : m);
    sb.append(":");
    long s = (milliSecs % (60 * 1000)) / 1000;
    sb.append(s < 10 ? "0" + s : s);
    return sb.toString();
}

From source file:Main.java

/**
 * Adds leading white space to the {@link StringBuffer}.
 * @param level The level in the tree used for leading white space (formating).
 * @param sb The {@link StringBuffer} to write to.
 *//* w ww. ja  v  a  2s  .  c  o  m*/
public static void appendWhiteSpace(int level, StringBuffer sb) {
    for (int i = 0; i < level; i++) {
        sb.append(LEADING_WHITE_SPACE_PER_LEVEL);
    }
}

From source file:Main.java

/** Use only for testing.
 *  @deprecated -- in 3.0 we can use Arrays.toString
 *  instead *///  www .  j av  a2s .  c o m
public static String arrayToString(int[] array) {
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    for (int i = 0; i < array.length; i++) {
        if (i > 0) {
            buf.append(" ");
        }
        buf.append(array[i]);
    }
    buf.append("]");
    return buf.toString();
}

From source file:Main.java

/** Use only for testing.
 *  @deprecated -- in 3.0 we can use Arrays.toString
 *  instead *//*  w ww.ja  v a 2  s.com*/
public static String arrayToString(Object[] array) {
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    for (int i = 0; i < array.length; i++) {
        if (i > 0) {
            buf.append(" ");
        }
        buf.append(array[i]);
    }
    buf.append("]");
    return buf.toString();
}

From source file:Main.java

/**
 * Add a closing tag for an element in a XML document buffer
 *
 * @param strXmlBuffer//from  w w w.  j a va2s  .c  om
 *            The XML document buffer
 * @param strTag
 *            The tag name of the element to add
 */
public static void endElement(StringBuffer strXmlBuffer, String strTag) {
    strXmlBuffer.append(TAG_CLOSE_BEGIN);
    strXmlBuffer.append(strTag);
    strXmlBuffer.append(TAG_END);
}

From source file:Main.java

/**
 * Share the crisis with your friend and/or the world.
 *///from  w w  w .java  2  s.  c om
public static Intent shareCrisis(String crisisID, String shortTitle) {
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");

    StringBuffer shareContent = new StringBuffer();
    shareContent.append(shortTitle);
    shareContent.append(" - ");
    shareContent.append("http://www.sigimera.org/crises/");
    shareContent.append(crisisID);

    shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareContent.toString());
    return shareIntent;
}

From source file:corner.orm.tapestry.service.captcha.RandomUtil.java

/**
 * ???//from   w w w  . j  av a  2  s.c  o m
 * @param string 
 * @return ?
 */
public static String encodeStr(String string) {
    String str = DigestUtils.md5Hex(string);
    StringBuffer sb = new StringBuffer();
    sb.append(str.charAt(7));
    sb.append(str.charAt(15));
    sb.append(str.charAt(23));
    sb.append(str.charAt(31));
    return sb.toString();
}

From source file:Main.java

public static void sendFeedback2(Context context) {

    String versionName = "";

    try {//from   w  ww.  ja  v a 2  s.  co m

        versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;

    } catch (NameNotFoundException e) {

        e.printStackTrace();
    }

    StringBuffer sb = new StringBuffer();
    sb.append("We would like to hear your feedback and improvement ideas. Please feel free to share below :")
            .append("\r\n").append("\r\n").append("\r\n").append("Attach Screenshots (if any) : ")
            .append("\r\n").append("\r\n").append("\r\n").append("Running on ").append(android.os.Build.MODEL)
            .append("\r\n").append("OS Version : ").append(android.os.Build.VERSION.RELEASE).append("\r\n")
            .append("Client Version : ").append(versionName);

    Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
            Uri.fromParts("mailto", "messageplus_feedback@starhub.com", null));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Message+ - Feedback");
    emailIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
    context.startActivity(Intent.createChooser(emailIntent, "Choose email client"));

}

From source file:Main.java

public static String toString(final Field field) {
    if (field == null) {
        return "null";
    }//from  w w  w.ja va 2 s . c  o m
    StringBuffer sb = new StringBuffer(field.getName());
    sb.append("(").append(field.getName()).append(")");
    return sb.toString();
}