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 joins(String[] arrays, String joinStr) {
    if (arrays == null) {
        return "";
    }//w  w  w  . j a v a  2 s.  c  o  m
    joinStr = StringUtils.hasText(joinStr) ? joinStr : ",";
    StringBuilder rs = new StringBuilder();
    for (String e : arrays) {
        rs.append(joinStr).append(e);
    }
    return rs.length() > 0 ? rs.substring(1) : "";
}

From source file:StringBuilderTester.java

public static String appendItems(List list) {
    StringBuilder b = new StringBuilder();

    for (Iterator i = list.iterator(); i.hasNext();) {
        b.append(i.next()).append(" ");
    }/* w  ww .ja  va2  s. c o  m*/

    return b.toString();
}

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

private static void printStorageAccount(StorageAccount storageAccount) throws Exception {
    StringBuilder output = new StringBuilder();
    output.append(String.format("Storage account id: %s\n", storageAccount.id()))
            .append(String.format("\tName: %s\n", storageAccount.name()))
            .append(String.format("\tGroup: %s\n", storageAccount.resourceGroup()))
            .append(String.format("\tPrimary blob endpoint: %s\n",
                    storageAccount.primaryBlobEndpoint().toString()))
            .append(String.format("\tAccount type: %s\n", storageAccount.accountType().toString()));

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

From source file:com.vectorization.server.master.Application.java

public static void printVersion() {
    StringBuilder sb = new StringBuilder();
    sb.append("vectorization-master Version " + VERSION + " for JVM.\n");
    sb.append("Copyright (c) 2014, Robert Moss. All rights reserved.\n");
    System.out.println(sb);// w w  w.ja v a2 s.c  o  m
}

From source file:de.tudarmstadt.ukp.dkpro.spelling.experiments.data.CreateVocabularyFromCorpus.java

private static void createVocabulary(Corpus corpus) throws Exception {
    Set<String> vocabulary = new TreeSet<String>();
    for (String token : corpus.getTokens()) {
        vocabulary.add(token);/*from   ww w  .  java 2s.c om*/
    }

    StringBuilder sb = new StringBuilder();
    for (String item : vocabulary) {
        sb.append(item);
        sb.append(System.getProperty("line.separator"));
    }

    FileUtils.writeStringToFile(new File("target/" + corpus.getName() + ".txt"), sb.toString());
}

From source file:Main.java

public static String toMacAddr(byte[] data) {
    if (data == null || data.length == 0) {
        return "";
    }/*  w  w  w  .j  a va 2  s.co  m*/

    StringBuilder result = new StringBuilder();

    for (byte b : data) {
        result.append(String.format("%02X:", b));
    }

    return result.toString().substring(0, result.toString().length() - 1);
}

From source file:Main.java

/**
 * Appends an SQL string to the given StringBuilder, including the opening
 * and closing single quotes. Any single quotes internal to sqlString will
 * be escaped.//from  w w w .j  a  v  a 2s  . c om
 *
 * This method is deprecated because we want to encourage everyone
 * to use the "?" binding form.  However, when implementing a
 * ContentProvider, one may want to add WHERE clauses that were
 * not provided by the caller.  Since "?" is a positional form,
 * using it in this case could break the caller because the
 * indexes would be shifted to accomodate the ContentProvider's
 * internal bindings.  In that case, it may be necessary to
 * construct a WHERE clause manually.  This method is useful for
 * those cases.
 *
 * @param sb the StringBuilder that the SQL string will be appended to
 * @param sqlString the raw string to be appended, which may contain single
 * quotes
 */
public static void appendEscapedSQLString(StringBuilder sb, String sqlString) {
    sb.append('\'');
    if (sqlString.indexOf('\'') != -1) {
        int length = sqlString.length();
        for (int i = 0; i < length; i++) {
            char c = sqlString.charAt(i);
            if (c == '\'') {
                sb.append('\'');
            }
            sb.append(c);
        }
    } else {
        sb.append(sqlString);
    }
    sb.append('\'');
}

From source file:Main.java

/** Join into string */
public static String join(String[] x) {
    StringBuilder sb = new StringBuilder();
    for (String token : x) {
        sb.append(token).append(" ");
    }// ww  w  . ja  v  a  2  s  . co m
    return sb.toString().trim();
}

From source file:Main.java

/** Join into string */
public static String join(List<String> x) {
    StringBuilder sb = new StringBuilder();
    for (String token : x) {
        sb.append(token).append(" ");
    }// w w w  .  jav  a  2  s . com
    return sb.toString().trim();
}

From source file:Main.java

public static String addStrings(Object... params) {
    StringBuilder stringBuilder = new StringBuilder();
    for (Object s : params) {
        stringBuilder.append(s);
    }//from w ww  . j a  va  2  s .c o  m
    return stringBuilder.toString();

}