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 getHead(String name) {
    char c = name.charAt(name.length() - 1);
    StringBuilder sb = new StringBuilder();
    sb.append(c);//from   w ww  .  j  av a 2s.c om
    return sb.toString();
}

From source file:Main.java

public static String getUserAgent() {
    StringBuilder model = new StringBuilder(android.os.Build.MODEL);
    if (model.toString().startsWith("\"")) {
        model.deleteCharAt(0);//  w w  w  .  j a va2 s.c o m
    }
    if (model.toString().endsWith("\"")) {
        model.deleteCharAt(model.length() - 1);
    }
    return model.toString();
}

From source file:Main.java

/**
 * Convert  date object  to  yyyy-MM-dd HH:mm:ss string  
 * /*from w  w  w.  j  av  a2s  . co m*/
 * @param date  date object
 * @return
 */
public static String DateToString(Date date) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    StringBuilder sb = new StringBuilder(dateFormat.format(date));
    return sb.toString();
}

From source file:Main.java

public static String getAudioDuration(int second) {

    StringBuilder sb = new StringBuilder();
    sb.append(second).append("\"");
    return sb.toString();
}

From source file:Main.java

public static String iCalFooter() {
    StringBuilder sb = new StringBuilder();
    sb.append("END:VCALENDAR").append("\n");
    return sb.toString();
}

From source file:Main.java

public static String encodeURL(String url, int width, int height) {
    if (TextUtils.isEmpty(url)) {
        return "";
    }//w w  w . jav  a 2 s  .c o m
    if (width <= 0 && height <= 0) {
        return url;
    }
    StringBuilder builder = new StringBuilder(url);
    if (!builder.toString().contains("?")) {
        builder.append("?");
    }
    url = builder.toString();
    if (!url.endsWith("&") && !url.endsWith("?")) {
        builder.append("&");
    }
    builder.append("width=").append(width).append("&").append("height=").append(height);
    return builder.toString();
}

From source file:Main.java

public static String getSMSMessage(String suid, String appId) {
    StringBuilder sb = new StringBuilder();
    sb.append(suid).append(",").append(appId);
    return sb.toString();
}

From source file:Main.java

/** @return Returns string for indentation to given level. */
public static final String indent(int level) {
    final StringBuilder buf = new StringBuilder();
    indent(buf, level);//from ww w .ja v  a 2 s. c  o  m
    return buf.toString();
}

From source file:Main.java

public static String bold(String msg) {
    StringBuilder sb = new StringBuilder("\033[1m");
    sb.append(msg).append("\033[0m");
    return sb.toString();
}

From source file:Main.java

public static String encodeHexString(byte[] bytes) {
    StringBuilder buffer = new StringBuilder();
    encodeHexString(bytes, buffer);//  w w  w. j  a v  a 2 s .  com
    return buffer.toString();
}