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 padLeft(String src, char c, int len) {
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < len - src.length(); i++)
        s.append(c);/*from   w  w  w  . ja  v  a  2 s  .com*/
    s.append(src);
    return s.toString();

}

From source file:Main.java

public static String arrayToString(String[] arr) {
    if (arr == null)
        return "<Null>";
    StringBuilder b = new StringBuilder();
    for (String str : arr) {
        b.append(str);//from  ww  w  .  ja v  a  2  s  .c o  m
        b.append(" ");
    }
    return b.toString();
}

From source file:net.eledge.android.toolkit.db.internal.SQLBuilder.java

public static String getWhereIdClause(Class<?> clazz) {
    StringBuilder sb = new StringBuilder(getIdField(clazz));
    sb.append(" = ?");
    return sb.toString();
}

From source file:Main.java

private static String removeDotSegments(StringBuilder uri, int offset, int limit) {
    if (offset >= limit) {
        return uri.toString();
    }/* w w w .jav  a 2  s  .  co m*/
    if (uri.charAt(offset) == '/') {
        offset++;
    }

    int segmentStart = offset;
    int i = offset;
    while (i <= limit) {
        int nextSegmentStart;
        if (i == limit) {
            nextSegmentStart = i;
        } else if (uri.charAt(i) == '/') {
            nextSegmentStart = i + 1;
        } else {
            i++;
            continue;
        }

        if (i == segmentStart + 1 && uri.charAt(segmentStart) == '.') {
            uri.delete(segmentStart, nextSegmentStart);
            limit -= nextSegmentStart - segmentStart;
            i = segmentStart;
        } else if (i == segmentStart + 2 && uri.charAt(segmentStart) == '.'
                && uri.charAt(segmentStart + 1) == '.') {
            int prevSegmentStart = uri.lastIndexOf("/", segmentStart - 2) + 2;
            int removeFrom = prevSegmentStart > offset ? prevSegmentStart : offset;
            uri.delete(removeFrom, nextSegmentStart);
            limit -= nextSegmentStart - removeFrom;
            i = prevSegmentStart;
        } else {
            i++;
            segmentStart = i;
        }
    }
    return uri.toString();
}

From source file:Main.java

public static String makeStrs(char ch, int len) {
    StringBuilder stringBuilder = new StringBuilder();
    for (int i = 0; i < len; ++i) {
        stringBuilder.append(ch);//ww  w. j  a va 2s  .  c  o m
    }

    return stringBuilder.toString();
}

From source file:Main.java

public static String getRepeatingString(int count, char character) {
    StringBuilder result = new StringBuilder();
    for (int i = 0; i < count; i++) {
        result.append(character);/*from  w w w  .j ava  2  s .  c  om*/
    }
    return result.toString();
}

From source file:Main.java

public static String concat(String... texts) {
    final StringBuilder builder = new StringBuilder();

    for (final String text : texts) {
        builder.append(text);/*  w w  w .ja va  2  s  .  c om*/
    }

    return builder.toString();
}

From source file:Main.java

public static String createJsTag(List<String> urls) {

    final StringBuilder sb = new StringBuilder();
    for (String url : urls) {
        sb.append(createJsTag(url));/*  w  w w.j a v  a  2s.com*/
    }
    return sb.toString();
}

From source file:Main.java

public static String validateAndFixUserPhoneNumber(String text) {
    try {/*from www .  j  a v  a 2s  . com*/
        text = text.trim();
        if (text.charAt(0) == '+') {
            text = text.substring(1);
        }
        BigInteger dummy = new BigInteger(text);
        if (text.charAt(0) == '8') {
            StringBuilder strBuilder = new StringBuilder(text);
            strBuilder.setCharAt(0, '7');
            text = strBuilder.toString();
        }
        if (text.charAt(0) != '7' || text.length() != 11) {
            throw new Exception();
        }
        text = "+" + text;
    } catch (Throwable t) {
        text = "";
        //LOGE("validateAndFixUserPhoneNumber: " + t.getMessage());
        t.printStackTrace();
    }

    return text;
}

From source file:Main.java

/**
 * uses a string builder to merge a set of strings
 *
 * @param args multiple string inputs//from   ww w .  java2s  .com
 * @return concatinated string
 */
public static String getTempString(String... args) {
    StringBuilder stringBuilder = new StringBuilder();
    for (String str : args) {
        stringBuilder.append(str);
    }

    return stringBuilder.toString();
}