Example usage for java.lang StringBuilder append

List of usage examples for java.lang StringBuilder append

Introduction

In this page you can find the example usage for java.lang StringBuilder append.

Prototype

@Override
    public StringBuilder append(double d) 

Source Link

Usage

From source file:Main.java

public static String NewCode() {
    StringBuilder sb = new StringBuilder();
    sb.append(random.nextInt(10));
    sb.append(random.nextInt(10));//from  w  ww .  j a  v a  2  s  .  c  o  m
    sb.append(random.nextInt(10));
    sb.append(random.nextInt(10));
    return sb.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

/**
 * Wraps an xm tag with '<' and '>'.
 *///from   ww w  . ja  v  a 2  s . c o  m
public static String xmlWrapStart(String str) {
    StringBuilder buf = new StringBuilder();
    buf.append('<');
    buf.append(str);
    buf.append('>');
    return buf.toString();
}

From source file:Main.java

private static byte[] getTextParameters(String fieldName, String fieldValue, String charset)
        throws UnsupportedEncodingException {
    StringBuilder sb = new StringBuilder();
    sb.append("Content-Disposition:form-data;name=\"");
    sb.append(fieldName);//  w ww . j a  v  a  2s  .c om
    sb.append("\"Content-Type:text/plain\r\n\r\n");
    sb.append(fieldValue);
    return sb.toString().getBytes(charset);
}

From source file:Main.java

private static String sanitizeFileName(String fileName) {
    StringBuilder sanitized = new StringBuilder();
    sanitized.append(fileName.replaceAll(FILE_NAME_PATTERN, "$1").replaceAll("[^A-Za-z0-9_\\-]", "_"));
    sanitized.append(fileName.replaceAll(FILE_NAME_PATTERN, "$2"));
    return sanitized.toString();
}

From source file:com.alibaba.jstorm.utils.SystemOperation.java

public static void umount(String name) throws IOException {
    StringBuilder sb = new StringBuilder();
    sb.append("umount ").append(name);
    SystemOperation.exec(sb.toString());
}

From source file:Main.java

public static String getExternalStoragePath() {
    StringBuilder sb = new StringBuilder();
    sb.append(Environment.getExternalStorageDirectory().getAbsolutePath());
    sb.append(File.separator);//w  w  w.  ja va 2s . c  o m
    sb.append(ROOT_DIR);
    sb.append(File.separator);
    return sb.toString();
}

From source file:Main.java

public static String generateStringContentType(final String charset) {
    StringBuilder buffer = new StringBuilder();
    buffer.append("application/x-www-form-urlencoded");
    if (charset != null) {
        buffer.append("; charset=");
        buffer.append(charset);/* w  ww.  j av  a 2s .  c om*/
    }
    return buffer.toString();
}

From source file:Main.java

/**
 * Convert a Cygwin based path to Windows format e.g. /cygdrive/c/file.txt
 * to C:\\file.txt//from w w w . jav a 2 s  . c  om
 * @param cygPath Cygwin based path
 * @return Windows path
 */
public static String toWindowsPath(String cygPath) {
    StringBuilder sb = new StringBuilder();
    sb.append(cygPath.charAt(10)).append(":\\");
    if (cygPath.length() > 12) {
        sb.append(cygPath.substring(12));
    }
    return sb.toString();
}

From source file:Main.java

public static void appendXmlBegin(StringBuilder sb, String param) {
    sb.append("<");
    sb.append(param);/*from  w  ww  .  jav a2 s.  c o  m*/
    sb.append(">");
}