List of usage examples for java.lang StringBuffer append
@Override public synchronized StringBuffer append(double d)
From source file:Main.java
public static void printNodeList(ArrayList<Node> nodeList) { StringBuffer buffer = new StringBuffer(); for (Node node : nodeList) { buffer.append(node.getNodeName() + " = " + node.getNodeValue() + " Attributes: " + attributesStr(node) + "\n"); }/*from w ww .jav a 2 s . c om*/ logger.info(buffer); }
From source file:Main.java
private static String byte2hexString(byte buf[]) { StringBuffer strbuf = new StringBuffer(buf.length * 2); int i;/*w w w. j a v a 2 s .c o m*/ for (i = 0; i < buf.length; i++) { strbuf.append(Integer.toString((buf[i] >> 4) & 0xf, 16) + Integer.toString(buf[i] & 0xf, 16)); } return strbuf.toString(); }
From source file:Main.java
public static String join(String[] arry, String with) { StringBuffer buf = new StringBuffer(); for (String s : arry) { if (buf.length() > 0) { buf.append(with); }/*from www .j ava 2s .co m*/ buf.append(s); } return buf.toString(); }
From source file:Main.java
private static StringBuffer appendElementStartHead(StringBuffer p_buffer, String p_name, String[][] attributes) {//from ww w . ja v a 2 s . c o m p_buffer.append("<"); p_buffer.append(p_name); if (attributes != null) { for (int i = 0; i < attributes.length; i++) { appendAttribute(p_buffer, attributes[i][0], attributes[i][1]); } } return p_buffer; }
From source file:Main.java
public static String formatAccountNo(String accountNo) { try {//from ww w . ja va2 s. co m StringBuffer s = new StringBuffer(); for (int i = 0; i < accountNo.length() - 10; i++) { s.append("*"); } StringBuffer sb = new StringBuffer(accountNo); sb.replace(6, accountNo.length() - 4, s.toString()); return sb.toString(); } catch (Exception e) { return accountNo; } }
From source file:Main.java
public static String bytesToHex(byte[] data) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { buf.append(byteToHex(data[i])); }/* w w w . j a v a2 s. c o m*/ return (buf.toString()); }
From source file:Main.java
public static String getRandomNum() { StringBuffer sb = new StringBuffer(); Random random = new Random(); for (int i = 0; i < 3; i++) { sb.append(random.nextInt(9)); }// w w w . ja va2 s .c o m return sb.toString(); }
From source file:StringUtils.java
/** * A simple routine which just repeates the arguments. This is useful * for creating something like a line or something. * * @param what String to repeat// w ww . j av a 2 s. co m * @param times How many times to repeat the string. * @return Guess what? * @since 2.1.98. */ public static String repeatString(String what, int times) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < times; i++) { sb.append(what); } return sb.toString(); }
From source file:Main.java
public static String toHexString(byte[] bytes) { if (bytes == null) { return null; }/*from w w w.j a v a2 s .c om*/ StringBuffer result = new StringBuffer(); for (byte b : bytes) { result.append(Integer.toString((b & 0xF0) >> 4, 16)); result.append(Integer.toString(b & 0x0F, 16)); } return result.toString(); }
From source file:com.ibm.watson.catalyst.corpus.tfidf.Template.java
public static Pattern getTemplatePattern(JsonNode document, String before, String after) { JsonNode terms = document.get("words"); List<String> words = new ArrayList<String>(); for (JsonNode termNode : terms) { if (termNode.get("frequency").asInt() < 5) continue; if (termNode.get("string").asText().length() < 2) continue; Term t = new Term(termNode); words.add(t.getTerm());//from ww w. ja va2s . c o m } StringBuffer sb = new StringBuffer(""); sb.append(before).append(makeOr(words)).append(after); Pattern p = Pattern.compile(sb.toString(), Pattern.CASE_INSENSITIVE); return p; }