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

/**
 * Build a tag <code><tagName/></code>.
 * //from   w w  w.  j  a  v a 2s  . co  m
 * @param pTagName
 *            name of the tag.
 * @return requested tag.
 */
public static String startEndTag(String pTagName) {
    StringBuilder tag = new StringBuilder();
    tag.append(TAG_START_LOW);
    tag.append(pTagName);
    tag.append(TAG_START_SLASH_SUP);
    return tag.toString();
}

From source file:Main.java

public static String binaryToHex(byte[] bytes) {
    StringBuilder sb = new StringBuilder(2 * bytes.length);
    for (byte b : bytes) {
        sb.append(String.format("%02x", b & 0xff));
    }//from  ww  w. ja va2  s.c  o m
    return sb.toString();
}

From source file:Main.java

public static String iteratorToString(Iterator<? extends Object> iter) {
    if (iter != null) {
        StringBuilder sb = new StringBuilder();
        for (; iter.hasNext();) {
            sb.append(iter.next().toString());
        }// w  ww . j a  va 2  s . c  o  m
        return sb.toString();
    } else {
        return "";
    }
}

From source file:Main.java

/**
 * Return a hexadecimal string representation of a byte array.
 *
 * @param bytes byte[]/*from  w  w w.j av a2  s.com*/
 * @return      String
 */
public static String byteToHex(byte[] bytes) {
    StringBuilder bcdString = new StringBuilder();

    for (Byte b : bytes) {
        bcdString.append(String.format("%02X ", b));
    }

    return bcdString.toString().trim();
}

From source file:Main.java

private static byte[] generateDigest(String algorithm, String... params) throws NoSuchAlgorithmException {
    StringBuilder sb = new StringBuilder(512);
    for (String s : params) {
        sb.append(s);/*w w  w .  j  ava  2s  .com*/
    }
    return MessageDigest.getInstance(algorithm).digest(sb.toString().getBytes());
}

From source file:Main.java

public static String revWords(String str) {
    StringBuilder sb = new StringBuilder();
    String revd = revStr(str);//from w w w  .j  av a  2 s.  co  m
    for (String s : revd.split(" ")) {
        sb.append(revStr(s));
        sb.append(" ");
    }
    return sb.toString();
}

From source file:Main.java

public static String maskString(String s) {
    StringBuilder stringbuilder = new StringBuilder(s.length());
    for (int i = 0; i < s.length(); i++) {
        stringbuilder.append("*");
    }//from ww  w  . j  ava  2  s .  c  o  m

    return stringbuilder.toString();
}

From source file:Main.java

private static String constructLocaleString(String language, String country, String variant) {
    final StringBuilder builder = new StringBuilder(language);
    if (TextUtils.isEmpty(language)) {
        return builder.toString();
    }/*ww  w . j a  v  a  2 s  .c om*/

    builder.append(language);

    if (TextUtils.isEmpty(country)) {
        return builder.toString();
    }

    builder.append(LOCALE_DELIMITER);
    builder.append(country);

    if (TextUtils.isEmpty(variant)) {
        return builder.toString();
    }

    builder.append(LOCALE_DELIMITER);
    builder.append(variant);

    return builder.toString();
}

From source file:Main.java

public static String arrayToString(final Object[] arr) {
    if (arr == null) {
        return "";
    }//from ww w  .  j a v a2 s  . c  om

    final StringBuilder sb = new StringBuilder();
    for (final Object item : arr) {
        sb.append(item);
    }
    return sb.toString();
}

From source file:Main.java

public static String floatArrayToString(float[] array) {
    StringBuilder builder = new StringBuilder();
    for (float v : array) {
        builder.append("" + v + " ");
    }/*from www  . j ava 2 s.c o m*/
    builder.append("\n");
    return builder.toString();
}