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 formatAmount(int amount, String currency) {
    if ("HUF".equals(currency)) {
        return String.format(Locale.US, "%d " + currency, amount);
    } else {/*from www. j a  va2 s  .co m*/
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("%d,%02d ");
        stringBuilder.append(currency);
        return String.format(Locale.US, stringBuilder.toString(), amount / 100, amount % 100);
    }
}

From source file:Main.java

public static StringBuilder value(StringBuilder builder, String type, String name, String value) {
    builder.append("<dia:attribute name=\"").append(name);
    builder.append("\"><dia:").append(type).append(">");
    builder.append(value);/*  w  w  w. j a v  a  2s. c o  m*/
    builder.append("</dia:").append(type).append("></dia:attribute>");
    return builder;
}

From source file:Main.java

public static String toLanguageTag(Locale locale) {
    StringBuilder languageTag = new StringBuilder();
    languageTag.append(locale.getLanguage());
    if (!isNullOrEmpty(locale.getCountry())) {
        languageTag.append('-').append(locale.getCountry());
    }//from  ww w.ja v a  2s .  co m
    if (!isNullOrEmpty(locale.getVariant())) {
        languageTag.append('-').append(locale.getVariant());
    }
    return languageTag.toString();
}

From source file:Main.java

public static String getTimeString(Calendar calendar) {
    if (calendar == null)
        return "";
    String hourString = String.format("%1$02d", calendar.get(Calendar.HOUR_OF_DAY));
    String minuteString = String.format("%1$02d", calendar.get(Calendar.MINUTE));
    StringBuilder dateStringBuilder = new StringBuilder();
    dateStringBuilder.append(hourString).append(":");
    dateStringBuilder.append(minuteString);
    return dateStringBuilder.toString();
}

From source file:mase.jbot.PresetCreator.java

private static void fillWeights(File file, double[] weights) throws IOException {
    StringBuilder sb = new StringBuilder();
    sb.append("weights=(");
    for (int i = 0; i < weights.length - 1; i++) {
        sb.append(weights[i]).append(",");
    }/*from  ww  w .  ja  v a 2s . c o  m*/
    sb.append(weights[weights.length - 1]).append(")");

    String descr = "description=(" + file.getName().replace("preset_", "").replace(".conf", "") + ")";

    String content = IOUtils.toString(new FileInputStream(file));
    content = content.replaceAll("weights\\s*=\\s*\\(.*\\)", sb.toString());
    content = content.replaceAll("description\\s*=\\s*\\(.*\\)", descr);
    System.out.println("Writting: " + file.getAbsolutePath() + " " + weights.length + " weights.");
    IOUtils.write(content, new FileOutputStream(file));
}

From source file:Main.java

public static void platformLog(String tag, String message) {
    StringBuilder s = new StringBuilder();
    s.append("ms[");
    s.append(System.currentTimeMillis());
    s.append("] ");
    s.append(message);/*from  ww  w .  j  a va2s .co m*/
    android.util.Log.v(tag, s.toString());
}

From source file:Main.java

public static String replaceAndEndnote(String text, String holderString, String replacement, String noteTag,
        String noteSplit) {//from w  ww.  j  a va 2 s  . co  m
    StringBuilder note = new StringBuilder();
    note.append(noteTag);

    String tmp = new String(text);
    int start = 0;
    while ((start = tmp.indexOf(holderString, start)) >= 0) {
        note.append(start + noteSplit);
        start += holderString.length();
    }
    start = note.length() - noteSplit.length();
    if (note.substring(start).equals(noteSplit))
        note.delete(start, note.length());

    return text.replace(holderString, replacement) + note;
}

From source file:Main.java

/**
 * @param str the string to right-side pad
 * @param num the minimum number of characters to return
 * @return 'str' with enough right padding to make it num characters long.
 *///from  w w w. j  av a  2s. c om
private static String padRight(String str, int num) {
    StringBuilder sb = new StringBuilder();
    sb.append(str);
    for (int count = str.length(); count < num; count++) {
        sb.append(" ");
    }

    return sb.toString();
}

From source file:Main.java

public static void appendHelper(StringBuilder sb, String tag, String val) {
    if (val != null)
        sb.append("\n" + tag + ": " + val);
}

From source file:Main.java

static public void appendAttribute(StringBuilder builder, String att, String value) {
    builder.append(" ");
    builder.append(att);/*w w w.  j av  a 2s.c o m*/
    builder.append("='");
    builder.append(value);
    builder.append("'");
}