Example usage for java.lang StringBuilder StringBuilder

List of usage examples for java.lang StringBuilder StringBuilder

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public StringBuilder() 

Source Link

Document

Constructs a string builder with no characters in it and an initial capacity of 16 characters.

Usage

From source file:Main.java

public static final String buildSelectApdu(String aid) {
    StringBuilder sb = new StringBuilder();
    sb.append("00A40400");
    sb.append(String.format("%02X", aid.length() / 2));
    sb.append(aid);//from w  w w  . j av a2s. c  om
    return sb.toString();
}

From source file:Main.java

private static String buildWhitespace(int numChars) {
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < numChars; i++) {
        sb.append(" ");
    }/*from w w w .j  av a 2  s  .c o m*/

    return sb.toString();
}

From source file:Main.java

public static String byte2hex(byte[] bytes) {
    StringBuilder sign = new StringBuilder();
    for (int i = 0; i < bytes.length; i++) {
        String hex = Integer.toHexString(bytes[i] & 0xFF);
        if (hex.length() == 1) {
            sign.append("0");
        }/*  w ww  . j ava  2  s . c  o  m*/
        sign.append(hex.toUpperCase());
    }
    return sign.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 ww w.ja v a  2s .  c  om*/
    }
    return sb.toString();
}

From source file:Main.java

public static String getDoubleDigit(int number) {
    StringBuilder builder = new StringBuilder();
    if (number >= 0 && number < 10) {
        builder.append("0");
    }/*from   ww w.  jav  a 2s.c o m*/
    builder.append(number).toString();
    return builder.toString();
}

From source file:Main.java

public static String getHexString(String s) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F')) {
            sb.append(c);/*from   w  w  w .  j a  v a  2s  .co m*/
        }
    }
    if ((sb.length() % 2) != 0) {
        sb.deleteCharAt(sb.length());
    }
    return sb.toString();
}

From source file:Main.java

private static String bytes2hex(byte[] bytes) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < bytes.length; i++) {
        String hex = Integer.toHexString(bytes[i] & 0XFF);
        if (hex.length() == 1) {
            sb.append("0").append(hex);
        } else {/*from ww w  .  j  a va  2 s. co m*/
            sb.append(hex);
        }
    }
    return sb.toString();
}

From source file:Main.java

private static String getUrlInfo(String prefix, String url, String content) {
    return new StringBuilder().append(prefix).append("<a href=\"").append(url).append("\">").append(content)
            .append("</a>").toString();
}

From source file:Main.java

public static String getSMSMessage(String suid, String appId) {
    StringBuilder sb = new StringBuilder();
    sb.append(suid).append(",").append(appId);
    return sb.toString();
}

From source file:Main.java

public static String filter(String xmlStr) {
    StringBuilder sb = new StringBuilder();
    char[] chs = xmlStr.toCharArray();
    //log.debug("filter before=" +chs.length);   
    for (char ch : chs) {
        if ((ch >= 0x00 && ch <= 0x08) || (ch >= 0x0b && ch <= 0x0c) || (ch >= 0x0e && ch <= 0x1f)) {
            //eat...   
        } else {/*from ww w  . j  a  v  a  2s. c  om*/
            sb.append(ch);
        }
    }
    //log.debug("filter after=" +sb.length());   
    return sb.toString();
}