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:net.eledge.android.toolkit.db.internal.SQLBuilder.java

public static String findAll(Class<?> clazz) {
    StringBuilder sb = new StringBuilder("SELECT * FROM ");
    sb.append(getTableName(clazz));/* w  w  w .  jav a 2  s .  c o  m*/
    return sb.toString();
}

From source file:Main.java

public static <T> String toString(List<T> values) {
    StringBuilder buffer = new StringBuilder();
    for (T value : values) {
        buffer.append(value).append(System.lineSeparator());
    }//  w w w .  j  a  v a  2s.com
    return buffer.toString();
}

From source file:Main.java

public static String generateRandom() {
    Random number = new Random();
    StringBuilder message = new StringBuilder();
    for (int i = 0; i < 1405; i++) {
        message.append('a' + number.nextInt(52));
    }/*from   w  ww.j  a  va2  s.  c o m*/
    return message.toString();
}

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 www  .j ava  2s .  c  o m*/
    return sb.toString();
}

From source file:Main.java

public static String readFile(String filePath) {
    File file = new File(filePath);
    StringBuilder fileContent = new StringBuilder("");
    if (file == null || !file.isFile()) {
        return fileContent.toString();
    }//w  ww  .j a  v  a  2  s  .c  o m
    BufferedReader reader = null;

    try {
        reader = new BufferedReader(new FileReader(file));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (!fileContent.toString().equals("")) {
                fileContent.append("\r\n");
            }
            fileContent.append(line);
        }
        reader.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
    return fileContent.toString();
}

From source file:Main.java

/**
 * Transformts the byte array to a/*from www. jav  a  2 s  . co m*/
 * hexadecimal String
 * @param in byte array
 * @return hexstring
 */
public static String bytesToHex(byte[] in) {
    final StringBuilder builder = new StringBuilder();
    for (byte b : in) {
        builder.append(String.format("%02x", b));
    }
    return builder.toString();
}

From source file:Main.java

public static String byteArrayToString(byte[] value, int length) {
    int max = Math.min(length, value.length);
    StringBuilder stringBuilder = new StringBuilder("");
    for (int i = 0; i < max; i++) {
        stringBuilder.append((char) value[i]);
    }//from w ww . ja  v a 2s.  c  om
    return stringBuilder.toString();
}

From source file:Main.java

public static String generateKey(String key, int position) {
    StringBuilder sb = new StringBuilder();

    sb.append(key);/*from w ww.ja v a  2s.c  o  m*/
    sb.append(":");
    sb.append(position);

    return sb.toString();
}

From source file:Main.java

private static String getVirtualImei() {
    StringBuilder result = new StringBuilder("1234567");
    for (int i = 0; i < 8; i++) {
        result.append((int) (Math.random() * 10));
    }//from   w w w  .java 2 s. c o  m
    return result.toString();
}

From source file:Main.java

public static String maskString(String str) {
    StringBuilder buf = new StringBuilder(str.length());
    for (int i = 0; i < str.length(); i++) {
        buf.append("*");
    }/*from  w  w  w  .  j a  va 2  s  .  c om*/
    return buf.toString();
}