List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:Main.java
public static String getByteArray(byte[] data) { final StringBuffer sb = new StringBuffer(); for (int i = 0; i < data.length; i++) { sb.append(data[i] + ","); }/*from ww w. j a v a 2 s . c o m*/ return sb.toString().substring(0, sb.length() - 1); }
From source file:Main.java
public static String escape(String text) { StringBuffer sb = new StringBuffer(); for (char c : text.toCharArray()) { escape(c, sb);//w ww . j a v a2 s . c o m } return sb.toString(); }
From source file:Main.java
public static String getTextFromNode(Node node, String defaultValue) { if (node == null) { return defaultValue; }/* w w w .j a v a 2 s .c o m*/ if (node.getNodeType() == Node.ATTRIBUTE_NODE) { return ((Attr) node).getValue(); } else if (node.getNodeType() == Node.TEXT_NODE) { return node.getNodeValue(); } else { StringBuffer text = new StringBuffer(); getTextFromNode(node, text, true); return text.toString().trim(); } }
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])); }/*from w w w.j a v a 2 s.co m*/ return strBuffer.toString(); }
From source file:Main.java
public static String getThreadId() { StringBuffer sb = new StringBuffer(30); sb.append("[thread Id: ").append(Thread.currentThread().getId()).append("] "); return sb.toString(); }
From source file:Main.java
public static String toString(final Field field) { if (field == null) { return "null"; }//from ww w . j a v a 2 s .c o m StringBuffer sb = new StringBuffer(field.getName()); sb.append("(").append(field.getName()).append(")"); return sb.toString(); }
From source file:Main.java
public static String indent(Integer position) { StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < position; i++) { stringBuffer.append(" "); }/*from w w w . jav a 2 s. c o m*/ return stringBuffer.toString(); }
From source file:Main.java
public static int getColorFromHex(String color) { if (color.contains("0x")) color = color.replace("0x", ""); // if (color.contains("#")) // color = color.replace("#", ""); // return Integer.parseInt(color, 16) + 0xFF000000; if (!color.contains("#")) { StringBuffer colorBuffer = new StringBuffer("#"); colorBuffer.append(color);// w ww . ja v a 2 s.c o m return Color.parseColor(colorBuffer.toString()); } // return Color.parseColor(color); // StringBuffer colorBuffer = new StringBuffer("0xff"); // colorBuffer.append(color); // int value = Integer.parseInt(colorBuffer.toString(), 16); // int red = ((value >> 24) & 0xFF) / 255; // int green = ((value >> 16) & 0xFF) / 255; // int blue = ((value >> 8) & 0xFF) / 255; // int alpha = ((value >> 0) & 0xFF) / 255; // Color.parseColor(colorString); // return Color.argb(alpha, red, green, blue); }
From source file:Main.java
/** Returns a {@link String} containing an enumeration of all {@link Thread}s in all {@link ThreadGroup}s. */ public static String enumerateAllThreads() { ThreadGroup root = Thread.currentThread().getThreadGroup(); // climb up the tree until we read the parent group while (root.getParent() != null) { root = root.getParent();//from www. java2 s . co m } final StringBuffer str = new StringBuffer(); collectThreadGroupInfo(root, str, ""); return str.toString(); }
From source file:Main.java
private static String toHex(byte[] buf) { if (buf == null) { return ""; }/* w w w .java2 s.c o m*/ StringBuffer result = new StringBuffer(2 * buf.length); for (byte aBuf : buf) { appendHex(result, aBuf); } return result.toString(); }