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 hex(byte[] array) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < array.length; ++i) {
        sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
    }/*w  w w. j a  v  a  2 s . c o m*/
    return sb.toString();
}

From source file:Main.java

public static CharSequence toLowerCase(CharSequence character) {
    if (character == null || character.equals("")) {
        return character;
    }/* w  w w .  j a v a 2s  .  c o m*/
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < character.length(); i++) {
        buffer.append(Character.toLowerCase(character.charAt(i)));
    }
    return buffer.toString();
}

From source file:Main.java

public static String readIt(InputStream stream) throws IOException {
    StringBuffer out = new StringBuffer();
    byte[] b = new byte[4096];
    for (int n; (n = stream.read(b)) != -1;) {
        out.append(new String(b, 0, n));
    }/*from   w  w  w.  ja v  a  2 s.  c o m*/
    return out.toString();
}

From source file:Main.java

public static String byteToChar(byte[] ucPtr) {
    final StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ucPtr.length; ++i) {
        char c = (char) ucPtr[i];
        sb.append(String.valueOf(c));
    }//from  w  ww . j  a v a2 s.c  o  m
    return sb.toString();
}

From source file:com.aw.swing.mvp.ui.common.LabelResolver.java

/**
 * lblF1 lblF2 lblF3//from w ww . jav a  2  s  .  co m
 *
 * @param keyCode
 * @return
 */
public static String getLabelNameForAction(int keyCode) {
    StringBuffer sb = new StringBuffer("lblF");
    sb.append(keyCode - (ActionDialog.KEY_F1 - 1));
    return sb.toString();
}

From source file:Main.java

/**
 * convert the reference of the numerical value letter into ths substance.
 * @param xml/*from w  w  w . j  av  a 2  s  .co m*/
 * @return
 */
public static String resolveNumEntities(String xml) {
    StringBuffer strb = new StringBuffer(xml);

    int index;
    int index2 = 0;
    int index3 = 0;

    while ((index = strb.toString().indexOf("&#", index2)) != -1) {
        index2 = strb.toString().indexOf(';', index + 1);
        index3 = strb.toString().indexOf("&#", index + 1);
        if (index2 == -1) {
            break;
        } else if (index3 != -1 && index2 > index3) {
            //We pass the entity description that is not right.
            index2 = index3;
        } else {
            try {
                char numericChar = (char) Integer.parseInt(strb.substring(index + 2, index2));
                String numericStr = String.valueOf(numericChar);
                strb.replace(index, index2 + 1, numericStr);
                index2 = index + numericStr.length();
            } catch (NumberFormatException e) {
                //We pass reference of the numerical value letter that is not right.
            }
        }
    }

    return strb.toString();
}

From source file:Main.java

public static final void println(String... argvs) {
    StringBuffer mStringBuffer = new StringBuffer();
    for (String argv : argvs) {
        mStringBuffer.append(argv);//from   w w w . j av a2 s .c  o  m
        mStringBuffer.append(" ");
    }
    System.out.println(mStringBuffer.toString());
}

From source file:Main.java

/**
 * Transform the raw ASCIIs to String by its value. "," is the separator.
 * //from  www .j a  v  a 2  s . c o  m
 * e.g. if ASCIIs = "97", the result is "a". if ASCIIs = "97,98", the result is "ab".
 * 
 * @param ASCIIs the raw ASCIIs require transforming
 * @return the String by its value
 */
public static String asciis2String(String ASCIIs) {
    String[] ASCIIss = ASCIIs.split(",");
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < ASCIIss.length; i++) {
        sb.append((char) __ascii2Char(Integer.parseInt(ASCIIss[i])));
    }
    return sb.toString();
}

From source file:Main.java

public static String getLineMethod() {
    StackTraceElement traceElement = ((new Exception()).getStackTrace())[2];
    StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getLineNumber()).append(" | ")
            .append(traceElement.getMethodName()).append("]");
    return toStringBuffer.toString();
}

From source file:Main.java

private static String urlEncode(String str, String charset) throws UnsupportedEncodingException {
    Pattern p = Pattern.compile("[\u4e00-\u9fa5]+");
    Matcher m = p.matcher(str);/*from  w w  w. ja  va2s .  c o  m*/
    StringBuffer b = new StringBuffer();
    while (m.find()) {
        m.appendReplacement(b, URLEncoder.encode(m.group(0), charset));
    }
    m.appendTail(b);
    return b.toString();
}