Example usage for java.lang StringBuilder toString

List of usage examples for java.lang StringBuilder toString

Introduction

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

Prototype

@Override
    @HotSpotIntrinsicCandidate
    public String toString() 

Source Link

Usage

From source file:Main.java

public static String multiStr(int count, String str) {
    if (null == str || str.equals("") || count <= 0) {
        return "";
    }/* w w w .  j a v  a2  s .  co m*/
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < count; i++)
        sb.append(str);
    return sb.toString();
}

From source file:Main.java

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

From source file:Main.java

public static List<String> populateStringList(int numberOfItems) {
    final String partialWord = "partialListParallel";
    List<String> dummyStringList = null;
    if (numberOfItems > 0) {
        dummyStringList = new ArrayList<String>();
        for (int i = 0; i < numberOfItems; i++) {
            final double randomNumber = (Math.random() * numberOfItems);
            final StringBuilder sb = new StringBuilder(partialWord).append(randomNumber);
            dummyStringList.add(sb.toString());
        }//from   w  w  w  .  j  a  v a2 s .c  o  m
    }
    return dummyStringList;
}

From source file:Main.java

public static String printBytes(byte[] bytes, int bytesPerLine) {
    StringBuilder builder = new StringBuilder();
    printBytes(bytes, builder, bytesPerLine);
    return builder.toString();
}

From source file:Main.java

public static String join(Collection<String> c, String sep) {
    StringBuilder sb = new StringBuilder();
    for (String str : c) {
        sb.append(str + sep);/*from  w w  w . j  ava 2  s. c o  m*/
    }
    return sb.toString();
}

From source file:Main.java

/**
 * Creates a Track name string from the name.
 * /* w  ww .  j  a  v a 2 s . co m*/
 * @param name the name of the track.
 * @return the gpx string.
 */
public static String getTrackNameString(String name) {
    StringBuilder sb = new StringBuilder();
    sb.append("<name>" + name + "</name>").append("\n");
    return sb.toString();
}

From source file:Main.java

/**
 * Wraps an xm tag with '&lt;' and '&gt;'.
 *//* w w w  . ja va 2  s  .  c  o  m*/
public static String xmlWrapStart(String str) {
    StringBuilder buf = new StringBuilder();
    buf.append('<');
    buf.append(str);
    buf.append('>');
    return buf.toString();
}

From source file:Main.java

public static String getUtteranceId(String packageName, long notificationId) {
    StringBuilder utteranceId = new StringBuilder();
    utteranceId.append(notificationId).append("_").append(packageName);
    return utteranceId.toString();
}

From source file:Main.java

public static String dupeString(String str, int repeats) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < repeats; i++) {
        sb.append(str);/*from   w w w . j  av a  2 s  . c  om*/
    }
    return sb.toString();
}

From source file:Main.java

/**
 * pads a string with 'F's (useful for pinoffset management)
 * @param s an [hex]string//  ww  w .  ja va  2 s.c o  m
 * @param len desired length
 * @return string right padded with 'F's
 */
public static String strpadf(String s, int len) {
    StringBuilder d = new StringBuilder(s);
    while (d.length() < len)
        d.append('F');
    return d.toString();
}