Example usage for java.lang StringBuilder append

List of usage examples for java.lang StringBuilder append

Introduction

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

Prototype

@Override
    public StringBuilder append(double d) 

Source Link

Usage

From source file:Main.java

public static String getClassFullName(String pkg, String name) {
    StringBuilder sb = new StringBuilder();
    if (pkg.length() != 0) {
        sb.append(pkg).append(".");
    }//from www .j a  v  a 2 s  .  c om
    sb.append(name);
    return sb.toString();
}

From source file:Main.java

public static String byteArrayToHex(byte[] a) {
    StringBuilder sb = new StringBuilder(a.length * 2);
    for (byte b : a)
        sb.append(String.format("%02x", b & 0xff));
    return sb.toString();
}

From source file:Main.java

private static String intJoin(int[] aArr, String sSep) {
    StringBuilder sbStr = new StringBuilder();
    for (int i : aArr) {
        sbStr.append(i);
        sbStr.append(sSep);//from  www  .  j  a  v  a2  s.  co m
    }
    return sbStr.toString();
}

From source file:Main.java

public static String joinArray(ArrayList arr) {
    StringBuilder sb = new StringBuilder();
    for (Object obj : arr) {
        sb.append(obj);
    }/*from w ww . j a  va 2  s  .  c  o m*/
    return sb.toString();
}

From source file:Main.java

protected static String toString(GregorianCalendar g1) {
    StringBuilder buffer = new StringBuilder();

    buffer.append(
            g1.get(Calendar.YEAR) + "/" + (g1.get(Calendar.MONTH) + 1) + "/" + g1.get(Calendar.DAY_OF_MONTH));
    buffer.append("  ");
    buffer.append(g1.get(Calendar.HOUR_OF_DAY) + ":" + g1.get(Calendar.MINUTE) + ":" + g1.get(Calendar.SECOND)
            + "." + g1.get(Calendar.MILLISECOND));

    return buffer.toString();
}

From source file:com.microsoft.azure.shortcuts.resources.samples.AvailabilitySetSample.java

private static void printAvailabilitySet(AvailabilitySet availabilitySet) throws Exception {
    StringBuilder output = new StringBuilder();
    output.append(String.format("Availability set id: %s\n", availabilitySet.id()))
            .append(String.format("\tName: %s\n", availabilitySet.name()))
            .append(String.format("\tGroup: %s\n", availabilitySet.resourceGroup()))
            .append(String.format("\tVirtual machine ids: \n\t%s",
                    StringUtils.join(availabilitySet.virtualMachineIds(), "\n\t")));

    System.out.println(output.toString());
}

From source file:Main.java

/** add serialized helper */
private static void addSerialized(StringBuilder result, String key, Object value) {
    result.append(key.replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE)).append(SERIALIZATION_SEPARATOR);
    if (value instanceof Integer) {
        result.append('i').append(value);
    } else if (value instanceof Double) {
        result.append('d').append(value);
    } else if (value instanceof Long) {
        result.append('l').append(value);
    } else if (value instanceof String) {
        result.append('s').append(value.toString().replace(SERIALIZATION_SEPARATOR, SEPARATOR_ESCAPE));
    } else if (value instanceof Boolean) {
        result.append('b').append(value);
    } else {/*w  ww .ja  v  a2s  .c om*/
        throw new UnsupportedOperationException(value.getClass().toString());
    }
    result.append(SERIALIZATION_SEPARATOR);
}

From source file:Main.java

private static String getLabelName(String name, char mnemonicKey, boolean addDot) {
    if (name.charAt(0) == mnemonicKey || mnemonicKey == '0') {
        return addDot ? name + "..." : name;
    }//w ww  . j av a  2  s  .  c o  m
    StringBuilder sb = new StringBuilder();
    sb.append(name).append('(').append(mnemonicKey).append(')');
    if (addDot) {
        sb.append("...");
    }
    return sb.toString();
}

From source file:Main.java

public static String getHour(int Hour) {
    StringBuilder hourStr = new StringBuilder();
    if (Hour < 10) {
        hourStr.append("0" + Hour);
    } else {//from   w  w  w.  java  2 s  .c  o  m
        hourStr.append(Hour);
    }

    return hourStr.toString();
}

From source file:ArrayReallocationDemo.java

private static void printArray(int[] data) {
    StringBuilder stringBuilder = new StringBuilder("[");
    for (int i = 0; i < data.length; i++) {
        stringBuilder.append(data[i]);
        if (i < data.length - 1)
            stringBuilder.append(", ");
    }/*from ww  w.j a  v  a  2  s  .  c  o m*/
    stringBuilder.append("]");
    System.out.println(stringBuilder);
}