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 getHexBytes(String header, byte[] bytes) {
    StringBuilder sb = new StringBuilder();
    if (header != null) {
        sb.append(header + ": ");
    }/*www .j  a v a  2s . c  o  m*/
    for (byte b : bytes) {
        sb.append(String.format("%02X ", b));
    }
    return sb.toString();
}

From source file:Main.java

public static String headerString(TableColumnModel m) {
    final StringBuilder result = new StringBuilder();
    result.append('[');
    for (Enumeration<TableColumn> en = m.getColumns(); en.hasMoreElements();) {
        final TableColumn tc = en.nextElement();
        result.append(headerString(tc));
        if (en.hasMoreElements()) {
            result.append(", ");
        }/*w  w  w  .ja va  2  s. co  m*/
    }
    result.append(']');
    return result.toString();
}

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

private static void printNSG(NetworkSecurityGroup nsg) throws Exception {
    StringBuilder output = new StringBuilder();
    output.append(String.format("Network Security Group ID: %s\n", nsg.id()))
            .append(String.format("\tName: %s\n", nsg.name()))
            .append(String.format("\tGroup: %s\n", nsg.resourceGroup()))
            .append(String.format("\tRegion: %s\n", nsg.region()));

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

From source file:Main.java

private static void appendInt(StringBuilder sb, int i) {
    sb.append(hexStringFromInt(FLAG_INT, NUM_LEN)).append(hexStringFromInt(i, NUM_LEN));
}

From source file:Main.java

/**
 * Convert the specified DOCTYPE attributes into a DOCTYPE string.
 *
 * @param name The DOCTYPE name./*w  w  w  . ja  v a 2  s.c  o m*/
 * @param publicId The public id of the DOCTYPE.
 * @param systemId The system id of the DOCTYPE.
 * @return
 */
public static String toDTDString(String name, String publicId, String systemId) {
    StringBuilder dtdBuilder = new StringBuilder();
    dtdBuilder.append("<!DOCTYPE ");
    dtdBuilder.append(name);
    if (publicId != null) {
        dtdBuilder.append(" PUBLIC ");
        dtdBuilder.append('"');
        dtdBuilder.append(publicId);
        dtdBuilder.append('"');
    }
    if (systemId != null) {
        dtdBuilder.append(' ');
        dtdBuilder.append('"');
        dtdBuilder.append(systemId);
        dtdBuilder.append('"');
    }
    dtdBuilder.append(">\n");
    return dtdBuilder.toString();
}

From source file:Main.java

public static String mapToXml(String s, LinkedHashMap linkedhashmap) {
    StringBuilder stringbuilder = new StringBuilder();
    stringbuilder.append("<key>");
    Object obj;/*from w  ww .  ja v  a 2s .  c  o  m*/
    for (Iterator iterator = linkedhashmap.entrySet().iterator(); iterator.hasNext(); stringbuilder
            .append((new StringBuilder("</")).append(obj).append(">").toString())) {
        java.util.Map.Entry entry = (java.util.Map.Entry) iterator.next();
        obj = entry.getKey();
        Object obj1 = entry.getValue();
        if (obj == null)
            obj = "unknow";
        if (obj1 == null)
            obj1 = "unknow";
        stringbuilder.append((new StringBuilder("<")).append(obj).append(">").toString());
        stringbuilder.append(obj1);
    }

    stringbuilder.append("</key>");
    return stringbuilder.toString();
}

From source file:Main.java

public static String join(String[] array, String delimiter) {
    StringBuilder sb = new StringBuilder();
    for (String str : array) {
        sb.append(str);
        sb.append(delimiter);//from w  w w  . j  a  va2 s  .com
    }
    return sb.toString();
}

From source file:Main.java

public static String toStringCollection(Collection list, String sep) {
    StringBuilder sb = new StringBuilder();
    for (Object s : list) {
        sb.append(s.toString());
        sb.append(sep);//from   w  w w. j a  v  a  2s  .  c  o m
    }
    return sb.toString();
}

From source file:Main.java

public static String numToK(String num) {
    StringBuilder sb = new StringBuilder();
    if (num.length() >= 5) {
        sb.append(num.substring(0, 2)).append("k");
        return sb.toString();
    } else {//w  ww .  j  a va 2  s.c o  m
        return num;
    }
}

From source file:Main.java

public static String formateComponentInfosToPrint(Component comp) {
    StringBuilder buf = new StringBuilder();
    buf.append(comp.getClass().getSimpleName());
    buf.append(" [");
    buf.append(comp.getName());/*from  w w w .ja va2  s .c o m*/
    if (comp instanceof JLabel)
        buf.append(",\"").append(((JLabel) comp).getText()).append("\"");
    buf.append(",");
    buf.append(comp.getClass().getName());
    buf.append(",");
    buf.append(comp.isVisible() ? "visible" : "not visible");
    buf.append(",");
    buf.append(comp.isValid() ? "valid" : "invalid");
    buf.append("]");
    return buf.toString();
}