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

private static String getThreadHead(ThreadInfo f) {
    StringBuffer sb = new StringBuffer();
    sb.append('"').append(f.getThreadName()).append('"');
    sb.append(" tid=0x" + Long.toHexString(f.getThreadId()));
    sb.append(" native=" + f.isInNative());
    sb.append(" suspended=" + f.isSuspended());
    return sb.toString();
}

From source file:Main.java

public static String appendPercentSymbol(int percent) {

    StringBuffer sb;

    sb = new StringBuffer();
    sb.append(percent);
    sb.append("%");

    return sb.toString();
}

From source file:Main.java

public static String getJsonTempleteId(String templateIdShort) {
    StringBuffer sb = new StringBuffer();
    sb.append("{");
    sb.append("\"template_id_short\":\"").append(templateIdShort).append("\"");
    sb.append("}");
    return sb.toString();
}

From source file:Main.java

private static void indent(final int i, StringBuffer b) {
    if (i > SPACES.length()) {
        b.append(SPACES);
        indent(i - SPACES.length(), b);/*  www .j av a2 s . c o  m*/
    } else {
        b.append(SPACES.substring(0, i));
    }
}

From source file:Main.java

/**
 * Given a code and description, join the items together using the join string
 * @param code//ww  w  . jav a 2s .co  m
 * @param description
 * @return
 */
public static String createCombinedKey(String code, String description) {

    if (code == null || code.trim().equals("")) {
        return null;
    }
    StringBuffer buffy = new StringBuffer();

    buffy.append(code);
    buffy.append(JOIN_STRING);
    buffy.append(description);
    return buffy.toString();
}

From source file:Main.java

public static String fillStringByBytesOnTail(String strValue, char ch, int iSign) {
    try {//from   w  w w  .  jav  a2s .com
        StringBuffer strTemp = new StringBuffer();
        strTemp.append(strValue);
        int iDifference = iSign - strValue.getBytes().length;
        if (iDifference <= 0)
            return strValue;
        for (int i = 0; i < iDifference; i++)
            strTemp.append(ch);
        return strTemp.toString();
    } catch (Exception ex) {
        return "";
    }
}

From source file:Main.java

/**
 * Write an XML close tag//www .j  a  v  a  2s . c  o  m
 * @param buffer StringBuffer to which the XML is appended
 * @param tagName name of the XML tag
 */
public static void closeTag(StringBuffer buffer, String tagName) {
    buffer.append("</");
    buffer.append(tagName);
    buffer.append(">");
}

From source file:Main.java

public static String fillStringOnTail(String strValue, char ch, int iSign) {
    try {/*from w  w w .ja va 2 s  .  c o  m*/
        StringBuffer strTemp = new StringBuffer();
        strTemp.append(strValue);
        int iDifference = iSign - strValue.length();
        if (iDifference <= 0)
            return strValue;
        for (int i = 0; i < iDifference; i++)
            strTemp.append(ch);
        return strTemp.toString();
    } catch (Exception ex) {
        return "";
    }
}

From source file:Main.java

static String toBinary(int num) {
    StringBuffer sb = new StringBuffer();

    for (int i = 0; i < 32; i++) {
        sb.append(((num & 1) == 1) ? '1' : '0');
        num >>= 1;/*from w ww.  jav  a  2s  . c o m*/
    }

    return sb.reverse().toString();
}

From source file:ai.emot.demo.EmotAIDemo.java

private static void printUsage() {

    StringBuffer use = new StringBuffer();
    use.append("usage: java EmotAIDemo <emot.ai.api.base.url> <emot.ai.api.access.token>\n\n");
    System.err.println(use);/*from w w w  .ja v  a 2  s.  c  om*/
}