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

public final static String getBlockId(String fileName, int nodeId, int blockId) {
    StringBuilder sb = new StringBuilder();
    sb.append(fileName);//  ww  w.  java2 s .  c o m
    sb.append(nodeId);
    sb.append(blockId);
    return sb.toString();
}

From source file:Main.java

public static String concatenateStrings(String[] targets) {
    StringBuilder sb = new StringBuilder();
    for (String target : targets) {
        sb.append(target);//  w w w. j  a  v a  2  s .  c  o m
    }
    return sb.toString();
}

From source file:Main.java

public static String makeQuestionmarks(int n) {
    if (n <= 0) {
        return "";
    }//from  w ww  . j av  a  2 s . co m
    StringBuilder builder = new StringBuilder("?");
    for (int i = 1; i < n; i++) {
        builder.append(",?");
    }
    return builder.toString();
}

From source file:Main.java

public static String convertByteArrayToHex(byte[] bytes) {
    if (bytes == null) {
        return null;
    }/*w w  w.  j av  a2 s. c om*/
    StringBuilder sb = new StringBuilder();
    for (byte b : bytes) {
        sb.append(String.format("%02X", b));
    }
    return sb.toString();
}

From source file:Main.java

public static String numToK(String num) {
    StringBuilder sb = new StringBuilder();
    if (num.length() >= 5) {
        sb.append(num.substring(0, 2)).append("k");
        return sb.toString();
    } else {//from  ww  w  .ja v a2  s .  c o m
        return num;
    }
}

From source file:Main.java

private static String printList(List<Long> list) {

    StringBuilder sb = new StringBuilder();
    for (Long id : list) {
        sb.append(id + whiteSpace);//from ww  w  . j ava2  s  . co m
    }
    return sb.toString();
}

From source file:Main.java

/**
 * Get a parameter name from a method name.
 *
 * @param methodName the method name/*from  w w  w .j  av a2s.  c  o  m*/
 * @return the parameter name
 */
public static String parameterName(final String methodName) {
    StringBuilder buf = new StringBuilder(methodName.substring(3));
    buf.setCharAt(0, Character.toLowerCase(methodName.charAt(3)));
    return buf.toString();
}

From source file:ReflectUtils.java

/**
 * Return a paranthesis enclosed, comma sepearated String of all
 * SimpleClass names in params.//from  ww w  .j ava2  s.  co  m
 * @param params
 * @return
 */
public static String getParamsString(Class[] params) {
    StringBuilder sb = new StringBuilder();
    addParamsString(sb, params);
    return sb.toString();
}

From source file:Main.java

public static String toHexString(byte[] bytes) {
    StringBuilder str = new StringBuilder();
    for (int i = 0; i < bytes.length; i++)
        str.append(byteToHex(bytes[i]));
    return str.toString();
}

From source file:Main.java

/** Join into string */
public static String join(String[] x) {
    StringBuilder sb = new StringBuilder();
    for (String token : x) {
        sb.append(token).append(" ");
    }/*from   w  w  w .  j  av  a  2 s  . co  m*/
    return sb.toString().trim();
}