Example usage for java.lang StringBuffer append

List of usage examples for java.lang StringBuffer append

Introduction

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

Prototype

@Override
    public synchronized StringBuffer append(double d) 

Source Link

Usage

From source file:Main.java

public static String getElementTagWithAttributes(String elementName, Map<String, String> attributes) {

    if (notEmptyStr(elementName) && attributes != null) {
        StringBuffer buffer = new StringBuffer();
        buffer.append(TAG_START).append(elementName);

        for (String key : attributes.keySet()) {
            buffer.append(" ").append(key).append("=").append("\"").append(attributes.get(key)).append("\"");
        }//from w w  w. j av a 2  s  . com
        return buffer.append("/").append(TAG_END).toString();
    }
    return null;
}

From source file:Main.java

public static String getGooglePlayUrl(String utmSource, String utmContent) {
    Uri.Builder builder = new Uri.Builder();
    builder.scheme("https");
    builder.authority("play.google.com");
    builder.path("/store/apps/details");
    builder.appendQueryParameter("id", "com.konifar.materialcat");

    if (utmSource != null && utmContent != null) {
        StringBuffer sb = new StringBuffer();
        sb.append("utm_source=");
        sb.append(utmSource);//from w w  w.j a  va  2s .  c o  m
        sb.append("&utm_medium=direct");
        sb.append("&");
        sb.append("utm_content=");
        sb.append(utmContent);
        builder.appendQueryParameter("referrer", sb.toString());
    }

    return builder.build().toString();
}

From source file:Main.java

/**In order to create a 64 bit binary string, the zero-padding on the left of the value is carried out
 *  @param value the string to pad//from   www  .  jav  a 2s. c  om
 *  @return Padded string
 */
public static String padding64(String value) {
    StringBuffer sb = new StringBuffer();
    sb.append(value);

    for (int i = 0; i < 64 - value.length(); i++) {
        sb.insert(0, "0");
    }

    return sb.toString();
}

From source file:Main.java

static String stringToHex(String str) {
    char[] chars = str.toCharArray();
    StringBuffer strBuffer = new StringBuffer();
    for (int i = 0; i < chars.length; i++) {
        strBuffer.append(Integer.toHexString((int) chars[i]));
    }//  w w w.  jav  a  2 s.  c  om
    return strBuffer.toString();
}

From source file:Endians.java

static String toString(byte[] a) {
    StringBuffer result = new StringBuffer("[");
    for (int i = 0; i < a.length; i++) {
        result.append(a[i]);
        if (i < a.length - 1)
            result.append(", ");
    }/* w  w w.j  a va  2s . co m*/
    result.append("]");
    return result.toString();
}

From source file:Main.java

private static void buildDexFile(String projectDir) {
    StringBuffer command = new StringBuffer();
    command.append(DX_PATH).append(" --dex --output=").append(projectDir).append("\\bin\\classes.dex")
            .append(" ").append(projectDir).append("\\bin");
    buildExeBatchFiles(command.toString(), "3.bat");
}

From source file:Main.java

static String replace(String str, String pattern, String replace) {
    int start = 0;
    int index = 0;
    StringBuffer result = new StringBuffer();

    while ((index = str.indexOf(pattern, start)) >= 0) {
        result.append(str.substring(start, index));
        result.append(replace);/* w  w w. j  a v a2s.c o m*/
        start = index + pattern.length();
    }
    result.append(str.substring(start));
    return result.toString();
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static Method getGetMethod(Class objectClass, String fieldName) {

    StringBuffer sb = new StringBuffer();

    sb.append("get");

    sb.append(fieldName.substring(0, 1).toUpperCase());

    sb.append(fieldName.substring(1));// w  w  w .j  av  a 2  s . com

    try {

        return objectClass.getMethod(sb.toString());

    } catch (Exception e) {

    }

    return null;

}

From source file:Main.java

private static String buildURI(String host, String location, boolean isSecure) {
    StringBuffer uri = new StringBuffer();
    if (isSecure)
        uri.append("https://");
    else//ww w .j a v  a 2  s  .  co  m
        uri.append("http://");

    uri.append(host);
    uri.append(location);
    return uri.toString();
}

From source file:Main.java

public static String toString(Principal[] principals) {
    if (principals == null || principals.length == 0) {
        return "<empty principals>";
    }/*from  w ww.  j av  a2s . c  om*/
    StringBuffer buf = new StringBuffer();

    buf.append("<");
    for (int i = 0; i < principals.length; i++) {
        Principal p = principals[i];
        buf.append("(class=");
        buf.append(p.getClass());
        buf.append(", name=");
        buf.append(p.getName());
        buf.append(")");
        if (i < principals.length) {
            buf.append(", ");
        }

    }
    buf.append(">");

    return buf.toString();
}