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

public static String toString(Field field) {
    StringBuffer sb = new StringBuffer(field.getName());
    sb.append("(").append(field.getName()).append(")");
    return sb.toString();
}

From source file:ju.ehealthservice.utils.ImageHandler.java

public static String formatString(byte[] bin) {
    StringBuffer data = new StringBuffer(Base64.encodeBase64String(bin));
    data.insert(0, Constants.IMAGE_HEADER);
    return data.toString();
}

From source file:Main.java

public static String generateRandomString(int len) {
    String all = "0123456789abcdefghijklmnopqrstuvwxyz";
    StringBuffer s = new StringBuffer();
    for (int i = 0; i < len; i++) {
        s.append(all.charAt(getRandomNum(36)));
    }//from   ww w  . j  ava  2  s. com

    return s.toString();
}

From source file:Main.java

public static String asciiToString(byte[] arrayList) {
    StringBuffer sbu = new StringBuffer();
    for (int i = 0; i < arrayList.length; i++) {
        sbu.append((char) arrayList[i]);
    }/*from   w w  w.j  av  a  2s  .  com*/
    return sbu.toString();
}

From source file:Main.java

public static String ByteArrayToString(byte[] arr) {
    StringBuffer sb = new StringBuffer();
    for (byte item : arr) {
        sb.append(String.format("%02X ", item & 0xFF));
    }/* ww w  .  j av  a 2  s  .c om*/

    return "{ " + sb.toString() + "}";
}

From source file:Main.java

/**
 * Returns a String containing the concatenation of text contained in the
 * given node. This includes Text node children, and Text node children of
 * Element nodes and their Element node children.
 * //  www.  j  a v  a2 s.c om
 * @param node a Node object
 * @return a concatenation of the descendent text
 */
public static String getChildrenText(Node node) {
    StringBuffer buf = new StringBuffer();
    getChildrenText(node.getChildNodes(), buf);
    return buf.toString();
}

From source file:Main.java

static String bytesToString(byte[] bytes) {
    StringBuffer sb = new StringBuffer();
    for (byte b : bytes) {
        sb.append(String.format("%02x ", b & 0xFF));
    }/*from   w  w w  .  jav  a2 s.c o m*/
    return sb.toString();
}

From source file:Main.java

public static String getClassFile(String name) {
    StringBuffer sb = new StringBuffer(name);
    name = name.replace('.', File.separatorChar) + ".class";
    sb.append(File.separator + name);
    return sb.toString();
}

From source file:Main.java

/**
 *
 * @param len//from   ww w.  ja  v a 2  s. com
 * @return
 */
public static String getRandomHex(int len) {
    Random r = new Random();
    StringBuffer sb = new StringBuffer();
    while (sb.length() < len) {
        sb.append(Integer.toHexString(r.nextInt()));
    }
    return sb.toString().substring(0, len).toUpperCase();
}

From source file:Main.java

public static String trimTail(StringBuffer sb, char tail) {
    if (sb.length() > 0 && sb.charAt(sb.length() - 1) == tail)
        sb.deleteCharAt(sb.length() - 1);
    return sb.toString();
}