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:se.uu.it.cs.recsys.dataloader.correction.CourseSelectionRecourseCorrecter.java

private static String replaceWrongCourseNameWithCorrect(String line, Map<String, String> wrongToCorrect) {
    StringBuilder lineCopy = new StringBuilder(line);

    wrongToCorrect.entrySet().stream().forEach(entry -> {
        if (lineCopy.toString().contains(entry.getKey())) {

            String contentCopy = lineCopy.toString();
            String replacedCopy = contentCopy.replace(entry.getKey(), entry.getValue());

            lineCopy.setLength(0);/*w ww .  j a v a  2  s  .co m*/

            lineCopy.append(replacedCopy);
        }
    });

    return lineCopy.toString();
}

From source file:Main.java

public static String generateRandomString(int len) {
    String str = "0123456789abcdefghijklmnopqrstuvwxyz";
    Random rnd = new Random();
    StringBuilder sb = new StringBuilder(len);
    for (int i = 0; i < len; i++) {
        sb.append(str.charAt(rnd.nextInt(str.length())));
    }//from  w  ww.j  av a  2  s  . c om
    return sb.toString();
}

From source file:Main.java

public static String toHexString(byte[] bytes, String pad) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < bytes.length; i++) {
        sb.append(String.format("%02x%s", bytes[i], pad));
    }/*from   www  .  j  a  va2 s. c o  m*/
    return sb.toString();
}

From source file:com.lexmark.saperion.services.GetFileFromSaperionECM.java

/**
 * @param content//  w w  w. j  a  v  a 2  s .c o m
 * @param boundaryValue
 */
private static void getFileFromResponseContent(StringBuilder content, String boundaryValue) {
    String[] strArray = content.toString().split(boundaryValue);
    for (String str : strArray) {
        // System.err.println("value of each string is: "+str);
        if (str.contains("application/octet-stream")) {
            String[] str2 = str.split("application/octet-stream");
            String str3 = str2[1];
            System.err.println("file value is: " + str3);
            // TODO remove this line if we need to get the file to the
            // viewer
            decodedBase64(str3);
            break;
        }
    }
}

From source file:Main.java

public static String getUuidStringFromByteArray(byte[] bytes) {
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < bytes.length; i++) {
        buffer.append(String.format("%02x", bytes[i]));
    }/*from   ww w  .java 2 s. co  m*/
    return buffer.toString();
}

From source file:Main.java

public final static <T> String join(Set<T> set, String separator) {
    StringBuilder sb = new StringBuilder();
    for (T t : set) {
        sb.append(t.toString()).append(separator);
    }//from   w  ww.  ja va2 s . com
    return sb.toString().substring(0, sb.toString().length() - separator.length());
}

From source file:Main.java

private static String capitalize(String original) {
    if (original.isEmpty()) {
        return original;
    }/*from   w  w  w. ja v  a2s .c o  m*/
    StringBuilder sb = new StringBuilder();
    sb.append(original.substring(0, 1).toUpperCase());
    sb.append(original.substring(1));
    return sb.toString();
}

From source file:Main.java

public static String repeat(String pattern, int count) {
    final StringBuilder builder = new StringBuilder();
    for (int i = 0; i < count; i++) {
        builder.append(pattern);//from  ww w. ja  va2 s.com
    }
    return builder.toString();
}

From source file:Main.java

/** Format XML value in tag
 *  @param buffer Buffer/*w  ww  . j a  v a 2s .co  m*/
 *  @param level  Indentation level
 *  @param tag    XML tag
 *  @param value  Value to place in tag
 *  @return XML for value in tag
 */
public static final String XML(final int level, final String tag, final String value) {
    final StringBuilder buffer = new StringBuilder();
    XML(buffer, level, tag, value);
    return buffer.toString();
}

From source file:Main.java

public static String formatDuration(Date begDate, Date endDate) {
    // TODO Auto-generated method stub
    StringBuilder builder = new StringBuilder(formatDate(begDate));
    builder.append(" - ");
    builder.append(formatDate(endDate));
    return builder.toString();
}