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 maskString(final String str) {
    final StringBuffer buf = new StringBuffer(str.length());
    for (int i = 0; i < str.length(); i++) {
        buf.append("*");
    }//w  ww.j  a  va  2 s .co m
    return buf.toString();
}

From source file:Main.java

public static String getInviteNum(int uid) {

    String str = String.valueOf(uid);
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 6 - str.length(); i++) {
        sb.append("0");
    }//from  w ww  .  j  ava2s  .c  o m
    sb.append(str);
    return sb.toString();
}

From source file:Main.java

public static String buildInfoHuafei() {
    StringBuffer sb = new StringBuffer();
    sb.append("<r>").append("<p n=\"");
    sb.append("mobilevoucher");
    sb.append("\"/>").append("</r>");
    return sb.toString();
}

From source file:Main.java

/**
 * converts an array of bytes into a hex string.
 * //from   ww  w  .  j ava  2  s .c om
 * @param bytes          array of bytes to convert to hex string
 * @return               hex string representation of input array
 */
public static String bytesToHexString(byte[] bytes) {
    if (bytes == null)
        return "null";
    StringBuffer sb = new StringBuffer();
    for (byte b : bytes) {
        sb.append(String.format("%02X ", b & 0xFF));
    }
    return sb.toString();
}

From source file:Main.java

public static String arrayToString(Object[] objArr) {
    if (objArr == null || objArr.length == 0) {
        return null;
    }/*  w w  w  . j  a va  2  s.c  om*/

    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < objArr.length; i++) {
        buf.append((i > 0 ? "," : "") + objArr[i]);
    }
    return buf.toString();
}

From source file:Main.java

public static String toConstantFormat(String str) {
    int n = str.length();
    List<Character> list = new ArrayList<Character>();
    char c;/*w  w w.j  av  a 2 s . co  m*/
    for (int i = 0; i < n; i++) {
        c = str.charAt(i);
        if (i != 0 && Character.isUpperCase(c)) {
            list.add('_');
        }
        list.add(Character.toUpperCase(c));
    }

    StringBuffer buffer = new StringBuffer();
    for (Character character : list) {
        buffer.append(character);
    }
    return buffer.toString();
}

From source file:com.enonic.cms.framework.util.UrlPathEncoder.java

public static String encodeUrlPathNoParameters(final String localPath, final String encoding) {
    if (localPath.equals("/")) {
        return localPath;
    }/*w  w  w  . j av a  2s. co m*/

    StringBuffer encodedPath = doEncodePath(localPath, encoding);

    return encodedPath.toString();
}

From source file:Main.java

private static String toHex(byte[] buf) {
    if (buf == null) {
        return "";
    }/*  w  w w  .j  ava  2 s. co  m*/
    StringBuffer result = new StringBuffer(2 * buf.length);
    for (int i = 0; i < buf.length; i++) {
        appendHex(result, buf[i]);
    }
    return result.toString();
}

From source file:Main.java

public static String toHex(byte[] buf) {
    if (buf == null)
        return "";
    StringBuffer result = new StringBuffer(2 * buf.length);
    for (int i = 0; i < buf.length; i++) {
        appendHex(result, buf[i]);//from  ww w  .ja  va  2s .  c  o  m
    }
    return result.toString();
}

From source file:Main.java

public static String stringAppend(String[] strings) {

    if (strings != null) {
        int len = strings.length;
        StringBuffer stb = new StringBuffer(strings[0]);
        for (int i = 1; i < len; i++) {
            stb.append(strings[i]);/* ww  w .ja v  a 2  s.c o m*/
        }
        return stb.toString();
    } else {
        return null;
    }

}