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

private static void printPassword() {
    String UPPER = "ABCDEFGHIJKLMNPQRSTUVWXYZ";
    String LOWER = "abcdefghijklmnpqrstuvwxyz";
    String NUMBER = "123456789";
    String SPECIAL = "!@#$%&*+?";
    Random randGen = new Random();

    StringBuffer buf = new StringBuffer();
    buf.append(LOWER.charAt(Math.abs(randGen.nextInt()) % LOWER.length()));
    buf.append(LOWER.charAt(Math.abs(randGen.nextInt()) % LOWER.length()));
    buf.append(NUMBER.charAt(Math.abs(randGen.nextInt()) % NUMBER.length()));
    for (int i = 0; i <= 4; i++) {
        buf.append(LOWER.charAt(Math.abs(randGen.nextInt()) % LOWER.length()));
    }//from  w w  w  .j a  v a2s.  c o  m
    buf.append(UPPER.charAt(Math.abs(randGen.nextInt()) % UPPER.length()));
    buf.append(LOWER.charAt(Math.abs(randGen.nextInt()) % LOWER.length()));
    System.out.println(buf.toString());
}

From source file:Main.java

private static void fillParams(String key, String val, StringBuffer sb) {
    sb.append(SPACE);
    sb.append("-e");
    sb.append(SPACE);//from  w w w  . j av a  2  s  .  c  om
    sb.append(key);
    sb.append(SPACE);
    sb.append(val);
}

From source file:Main.java

private static void appendHex(StringBuffer result, byte b) {
    result.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
}

From source file:Main.java

public static void wrapRightSign(StringBuffer buf, String name) {
    buf.append("</").append(name).append(">");
}

From source file:Main.java

public static void wrapLeftSign(StringBuffer buf, String name) {
    buf.append("<").append(name).append(">");
}

From source file:Main.java

public static StringBuffer appendHead(StringBuffer sb) {
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    return sb;/* w ww.j  a v  a2s  . c o m*/
}

From source file:Main.java

public static StringBuffer appendLine(StringBuffer sb) {
    sb.append("\n");
    return sb;
}

From source file:Main.java

private static void appendHex(StringBuffer sb, byte b) {
    sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
}

From source file:Main.java

public static void adToXML(Object[] args, String rootName, String elemName, StringBuffer xmlStr) {
    xmlStr.append("<" + rootName + ">");

    for (Object arg : args) {
        if (arg == null)
            arg = "";
        xmlStr.append("<" + elemName + ">" + arg.toString() + "</" + elemName + ">");
    }//from   www .ja va 2 s  . co  m

    xmlStr.append("</" + rootName + ">");

}

From source file:Main.java

public static StringBuffer addStartTag(StringBuffer buf, String tagname) {
    buf.append(LT).append(tagname).append(GT);
    return buf;/*w w  w  .j  av  a  2  s .  c  om*/
}