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 arrayToString(Object[] objArr) {
    if (objArr == null || objArr.length == 0) {
        return null;
    }//from w ww .jav  a  2 s. c o m

    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < objArr.length; i++) {
        buf.append((i > 0 ? "," : "") + objArr[i]);
    }
    return buf.toString();
}

From source file:Main.java

public static String ctorToString(final Constructor constructor) {
    if (constructor == null) {
        return "null";
    }/* ww  w.j  a va 2s.  co  m*/

    Class[] params = constructor.getParameterTypes();
    StringBuffer sb = new StringBuffer(constructor.getName());
    sb.append("(");
    for (int i = 0; i < params.length; i++) {
        String s = params[i].getName();
        sb.append(s);
        if (i < params.length - 1) {
            sb.append(", ");
        }
    }
    sb.append(")");
    return sb.toString();
}

From source file:Main.java

public static String indent(Integer position) {
    StringBuffer stringBuffer = new StringBuffer();
    for (int i = 0; i < position; i++) {
        stringBuffer.append(" ");
    }//from  ww w  .j ava  2 s.com
    return stringBuffer.toString();
}

From source file:Main.java

private static String getMd5(String md5) throws Exception {
    MessageDigest md = java.security.MessageDigest.getInstance(MD5);
    byte[] array = md.digest(md5.getBytes(CHARSET_NAME));
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < array.length; ++i) {
        sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
    }//from  w  w w. j a  v a  2s  .co  m
    return sb.toString();
}

From source file:Main.java

public static String toString(byte b) {
    StringBuffer sb = new StringBuffer(2);
    int i = (b & 0xF0) >> 4;
    int j = b & 0x0F;
    sb.append(new Character((char) ((i > 9) ? (65 + i - 10) : (48 + i))));
    sb.append(new Character((char) ((j > 9) ? (65 + j - 10) : (48 + j))));

    return sb.toString();
}

From source file:Main.java

public static String getInviteNum(int uid) {

    String str = String.valueOf(uid);
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 6 - str.length(); i++) {
        sb.append("0");
    }//from ww w . j  av  a  2 s. co m
    sb.append(str);
    return sb.toString();
}

From source file:Main.java

public static String bytesToPdu(byte[] bytes) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < bytes.length; i++) {
        sb.append(byteToPdu(bytes[i] & 0xFF));
    }//  w w w  .j av  a  2  s  . c  om
    return sb.toString();
}

From source file:Main.java

private static String toStringByArray(Object[] value) {
    StringBuffer sb = new StringBuffer(100);
    String type = value[0].getClass().getName();
    sb.append("{").append(type).append("@");
    for (int i = 0; i < value.length; i++) {
        sb.append(esc(value[i].toString())).append(",");
    }/*from  w  w w . j a v a2 s  . c o m*/
    return sb.substring(0, sb.length() - 1) + "}";
}

From source file:Main.java

public static String stringArrayToString(String[] array) {
    StringBuffer result = new StringBuffer();
    for (int i = 0; i < array.length - 1; i++) {
        result.append(array[i]).append(TAB);
    }/*from   w  ww .  j  a va 2s.  c o  m*/
    result.append(array.length - 1);
    return result.toString();
}

From source file:Main.java

private static String makeIndent(int indentOffset) {
    /* 448 */if (indentOffset == 0) {
        /* 449 */return "";
        /*     */}
    /* 451 */StringBuffer sb = new StringBuffer();
    /* 452 */while (indentOffset > 0) {
        /* 453 */sb.append(' ');
        /* 454 */indentOffset--;
        /*     */}
    /* 456 */return sb.toString();
    /*     */}/*w w  w  . jav  a 2 s  .  c  om*/