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

public StringBuilder(CharSequence seq) 

Source Link

Document

Constructs a string builder that contains the same characters as the specified CharSequence .

Usage

From source file:Main.java

public static String formatPhoneNumber(String mobile) {
    StringBuilder maskNumber = new StringBuilder(11);
    maskNumber.append(mobile.substring(0, 3));
    maskNumber.append("****");
    maskNumber.append(mobile.substring(7, mobile.length()));
    return maskNumber.toString();
}

From source file:Main.java

public static String maskString(String paramString) {
    StringBuilder localStringBuilder = new StringBuilder(paramString.length());
    for (int i = 0; i < paramString.length(); i++)
        localStringBuilder.append("*");
    return localStringBuilder.toString();
}

From source file:Main.java

public static String prettifyFingerprint(String fingerprint) {
    StringBuilder builder = new StringBuilder(fingerprint);
    builder.insert(8, " ");
    builder.insert(17, " ");
    builder.insert(26, " ");
    builder.insert(35, " ");
    return builder.toString();
}

From source file:Main.java

public static String intToHexString_4(int a) {
    StringBuilder stringBuilder = new StringBuilder("");
    int v = a & 0xFFFF;
    String hv = Integer.toHexString(v);
    if (hv.length() == 1) {
        stringBuilder.append("000");
    } else if (hv.length() == 2) {
        stringBuilder.append("00");
    } else {//from   ww  w  .  j a  va2 s . c  o m
        stringBuilder.append("0");
    }
    stringBuilder.append(hv);
    return stringBuilder.toString();
}

From source file:Main.java

public static String splStrToWebUrl(String... strings) {
    StringBuilder sBuilder = new StringBuilder("http://");
    int i = 0;/*from   w  w  w. j  a  v a2 s  .c om*/
    for (String string : strings) {
        sBuilder.append(string);
        if (i < strings.length - 1)
            sBuilder.append("/");
        i++;
    }
    return sBuilder.toString();
}

From source file:Main.java

public static String dumpBytesAsString(byte[] data) {
    final StringBuilder stringBuilder = new StringBuilder(data.length);
    for (byte byteChar : data) {
        stringBuilder.append(String.format("%02X ", byteChar));
    }/*from  ww w.  jav  a2  s  . c o  m*/
    return stringBuilder.toString();
}

From source file:Main.java

public static String printStackTrace(StackTraceElement[] stack) {
    StringBuilder output = new StringBuilder(1000);
    appendThreadStackTrace(output, stack);
    return output.toString();
}

From source file:Main.java

public static String encodeHexString(byte abyte0[]) {
    StringBuilder stringbuilder = new StringBuilder("");
    if (abyte0 != null) {
        for (int i = 0; i < abyte0.length; i++) {
            Object aobj[] = new Object[1];
            aobj[0] = Integer.valueOf(0xff & abyte0[i]);
            stringbuilder.append(String.format("%02x", aobj));
        }// w ww.ja v  a2s.  com

    }
    return stringbuilder.toString();
}

From source file:Main.java

public static String bold(String msg) {
    StringBuilder sb = new StringBuilder("\033[1m");
    sb.append(msg).append("\033[0m");
    return sb.toString();
}

From source file:Main.java

public static String byte2HexStr(byte[] b) {
    String stmp = "";
    StringBuilder sb = new StringBuilder("");
    for (int n = 0; n < b.length; n++) {
        stmp = Integer.toHexString(b[n] & 0xFF);
        sb.append((stmp.length() == 1) ? "0" + stmp : stmp);
        sb.append("");
    }/*ww  w  .j a v a 2s.  co  m*/
    return sb.toString().toUpperCase().trim();
}