Example usage for java.lang StringBuffer toString

List of usage examples for java.lang StringBuffer toString

Introduction

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

Prototype

@Override
    @HotSpotIntrinsicCandidate
    public synchronized String toString() 

Source Link

Usage

From source file:Main.java

/**
 * /* w ww  .jav  a 2 s  . c  o m*/
 * @param emojiName
 * @return
 */
public static String formatFaces(String emojiName) {
    StringBuffer sb = new StringBuffer();
    sb.append("<img src=\"emoji_");
    sb.append(emojiName);
    sb.append("\">");
    return sb.toString();
}

From source file:Main.java

public static String truncateChange(String change, boolean isPercentChange) {
    String weight = change.substring(0, 1);
    String ampersand = "";
    if (isPercentChange) {
        ampersand = change.substring(change.length() - 1, change.length());
        change = change.substring(0, change.length() - 1);
    }/*from   w  w w  . ja v a  2 s .  c o m*/
    change = change.substring(1, change.length());
    double round = (double) Math.round(Double.parseDouble(change) * 100) / 100;
    change = String.format("%.2f", round);
    StringBuffer changeBuffer = new StringBuffer(change);
    changeBuffer.insert(0, weight);
    changeBuffer.append(ampersand);
    change = changeBuffer.toString();
    return change;
}

From source file:Main.java

public static String maskString(String str) {
    StringBuffer buf = new StringBuffer(str.length());
    for (int i = 0; i < str.length(); i++) {
        buf.append("*");
    }//from   www  . j  a va2  s  . co  m
    return buf.toString();
}

From source file:Main.java

public static String printNode(Node node) {
    StringBuffer sBuffer = new StringBuffer();

    printNode(sBuffer, node);/*from  ww  w .j av a  2  s.  c  o m*/

    return sBuffer.toString();
}

From source file:Main.java

/**
 * Convert the list of Integers into a comma separated
 * string so that it's easy to load back in.
 * @param list//from  w ww .j  a  v a  2 s  .co  m
 * @return
 */
public static String toString(List<?> list) {
    StringBuffer buf = new StringBuffer();
    for (Object o : list)
        buf.append(o + ",");
    buf.deleteCharAt(buf.length() - 1);
    return buf.toString();
}

From source file:Main.java

/**
 * The Internal helper method converts a byte[] to a String
 * /* ww  w . j  a  va 2 s  .  c  o  m*/
 * @param byte[] to transform in a String 
 * @return String of the byte[]
 */
public static String bytesToString(byte[] bytes) {
    StringBuffer sb = new StringBuffer();
    for (byte b : bytes) {
        sb.append(String.format("%02x ", b & 0xFF));
    }
    return sb.toString();
}

From source file:StringUtils.java

/**
 *  A simple routine which just repeates the arguments.  This is useful
 *  for creating something like a line or something.
 *
 *  @param what String to repeat//from   w w w . j a  v  a 2  s  .  co m
 *  @param times How many times to repeat the string.
 *  @return Guess what?
 *  @since 2.1.98.
 */
public static String repeatString(String what, int times) {
    StringBuffer sb = new StringBuffer();

    for (int i = 0; i < times; i++) {
        sb.append(what);
    }

    return sb.toString();
}

From source file:Main.java

public static String bytesToPdu(byte[] bytes) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < bytes.length; i++) {
        sb.append(byteToPdu(bytes[i] & 0xFF));
    }//from  w  w  w . j  av a 2 s.com
    return sb.toString();
}

From source file:Main.java

/**
 * Given a code and description, join the items together using the join string
 * @param code/*from   w ww.  j  a  v a2 s.  com*/
 * @param description
 * @return
 */
public static String createCombinedKey(String code, String description) {

    if (code == null || code.trim().equals("")) {
        return null;
    }
    StringBuffer buffy = new StringBuffer();

    buffy.append(code);
    buffy.append(JOIN_STRING);
    buffy.append(description);
    return buffy.toString();
}

From source file:Main.java

public static String getThreadTree() {
    ThreadGroup root = Thread.currentThread().getThreadGroup();
    while (root.getParent() != null) {
        root = root.getParent();/*from  w  w  w .  j a v a2  s. c  om*/
    }
    StringBuffer buffer = new StringBuffer();

    buffer.append(root.toString()).append("\r");
    visit(root, 1, buffer);
    return buffer.toString();
}