List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:Main.java
public static String bytesToString(byte[] bytes) { if (bytes == null) return ""; StringBuffer sb = new StringBuffer(); for (byte b : bytes) { sb.append(String.format("%02x ", b & 0xFF)); }/* w w w . ja v a2s . com*/ String str = sb.toString(); if (str.length() > 0) { str = str.substring(0, str.length() - 1); } return str; }
From source file:Main.java
public static String getNodesText(NodeList nodes) { StringBuffer ret = new StringBuffer(); for (int i = 0, l = nodes.getLength(); i < l; i++) { ret.append(nodes.item(i).getTextContent()); }//from ww w . ja va 2 s . c o m return ret.toString(); }
From source file:Main.java
public static String toHex(byte[] buf) { if (buf == null) { return ""; }//from ww w .jav a 2 s . c o m StringBuffer result = new StringBuffer(2 * buf.length); for (int i = 0; i < buf.length; i++) { appendHex(result, buf[i]); } return result.toString(); }
From source file:Main.java
public static String toXML(String valor) { StringBuffer str = new StringBuffer(); for (int i = 0; i < valor.length(); ++i) str.append(toXML(valor.charAt(i))); return str.toString(); }
From source file:Main.java
public static String inputStreamToString(InputStream in_temp) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(in_temp)); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null) { buffer.append(line);//from w w w. j a va 2s .c om } return buffer.toString(); }
From source file:Main.java
public static String getJsonMessageMass(String msgId) { StringBuffer sb = new StringBuffer(); sb.append("{"); sb.append("\"msg_id\":\"").append(msgId).append("\""); sb.append("}"); return sb.toString(); }
From source file:Main.java
private static StringBuffer printBuffer(Logger logger, StringBuffer sb, boolean clearBuffer) { if (logger != null) { logger.debug(sb.toString()); } else {/*from ww w .j a v a2 s . c om*/ System.out.println(sb.toString()); } if (clearBuffer) sb = new StringBuffer(); return sb; }
From source file:Main.java
public static String toXml(String fieldName, String fieldValue) { StringBuffer xmlBuf = new StringBuffer(); xmlBuf.append(startTag(fieldName));/*www. ja va 2 s . c o m*/ xmlBuf.append(fieldValue); xmlBuf.append(endTag(fieldName)); return xmlBuf.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 v a2 s .com } return sb.toString(); }
From source file:Main.java
/** * Reads 4 bytes and concatenates them into a String. * This pattern is used for ID's of various kinds. *//* w w w. j a va 2 s . c om*/ public static String read4Chars(RandomAccessFile raf) throws IOException { StringBuffer sbuf = new StringBuffer(4); for (int i = 0; i < 4; i++) { char ch = (char) raf.read(); sbuf.append(ch); } return sbuf.toString(); }