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 static String wrapHtmlTag(String s, String tag) {
    StringBuilder sb = new StringBuilder("<html><");
    sb.append(tag).append(">");
    sb.append(s);/*from w ww.ja  v a  2 s .  c  om*/
    sb.append("</").append(tag).append("></html>");
    return sb.toString();
}

From source file:Main.java

/** Returns all stack traces, including lock info. */
public static String getAllStackTraces() {
    ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
    boolean monitor = threadMXBean.isObjectMonitorUsageSupported();
    boolean sync = threadMXBean.isSynchronizerUsageSupported();
    ThreadInfo[] allThreadInfo = threadMXBean.dumpAllThreads(monitor, sync);
    StringBuilder sb = new StringBuilder("Stack Trace Report:\n");
    buildTrace(allThreadInfo, sb);//from   w w w . j  av  a 2 s .  c o m
    return sb.toString();
}

From source file:org.projecthdata.social.api.connect.HDataServiceProvider.java

/**
 * Get the access token url, based on the url for an EHR. This will be the
 * host of the EHR with the path /auth/token
 * /*  w ww  .j a  v a2  s . c om*/
 * @param ehrUrl
 * @return
 */
public static String getAccessTokenUrl(String ehrUrl) {
    StringBuilder builder = getBaseUrl(ehrUrl);
    builder.append(accessTokenUrlPath);
    return builder.toString();
}

From source file:architecture.ee.web.attachment.AbstractAttachmentManager.java

protected static String listToString(List<String> list) {
    StringBuilder sb = new StringBuilder();
    for (String element : list) {
        sb.append(element).append(",");
    }//  w w w.j  a v  a 2 s  .  c  o m
    return sb.toString();
}

From source file:Main.java

public static String getCurrentMonthFirstDay(long time) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM", Locale.CHINA);
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(dateFormat.format(time));
    stringBuilder.append("-");
    stringBuilder.append(1);/* w ww .  j  a  va 2  s.  c o m*/
    return stringBuilder.toString();
}

From source file:Main.java

public static String long2String(long l, int minDigits) {
    StringBuilder s = new StringBuilder(minDigits);
    s.append(Long.toString(l));//from w w  w  .  j av a  2 s.co m
    while (s.length() < minDigits) {
        s.insert(0, "0");
    }
    return s.toString();
}

From source file:Main.java

public static String toString(InputStream in) throws IOException {
    if (in == null) {
        return null;
    }//  ww  w  . j  ava 2s  .  c om
    BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(in, 8 * 1024)));
    StringBuilder result = new StringBuilder();
    String line = null;
    while ((line = br.readLine()) != null) {
        result.append(line);
    }
    return result.toString();
}

From source file:Main.java

public final static <K, V> String keyJoin(Map<K, V> map, String separator) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<K, V> entry : map.entrySet()) {
        sb.append(String.valueOf(entry.getKey())).append(separator);
    }/* w ww.  j a  v a  2 s. c  o  m*/
    return sb.toString().substring(0, sb.toString().length() - separator.length());
}

From source file:Main.java

public static String randomNumericString(int stringLength) {
    Random generator = new Random();
    StringBuilder randomStringBuilder = new StringBuilder();
    for (int i = 0; i < stringLength; i++) {
        randomStringBuilder.append(generator.nextInt(9));
    }/*from w w w  .j  a  v  a 2s .c o  m*/
    return randomStringBuilder.toString();
}

From source file:Main.java

public static String[] splitByCamelCase(String name) {
    List<String> parts = new ArrayList<String>();
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < name.length(); i++) {
        if (i > 0 && Character.isUpperCase(name.charAt(i))) {
            parts.add(b.toString());
            b = new StringBuilder();
        }//from w w w . j a  va2 s.  c om
        b.append(Character.toLowerCase(name.charAt(i)));
    }
    parts.add(b.toString());
    return parts.toArray(new String[] {});
}