List of usage examples for java.lang StringBuilder toString
@Override
@HotSpotIntrinsicCandidate
public String toString()
From source file:Main.java
public static String dumpAllThreads() { ThreadInfo[] dumps = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true); StringBuilder out = new StringBuilder("Thread Dump\n"); for (ThreadInfo dump : dumps) { out.append("-------------------------\n").append(dump); }// w ww . ja v a2s. com return out.toString(); }
From source file:Main.java
@NonNull public static String readStream(InputStream stream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line = ""; StringBuilder result = new StringBuilder(); while ((line = reader.readLine()) != null) { result.append(line);//w ww .j av a 2s . c o m } stream.close(); return result.toString(); }
From source file:Main.java
public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null;// w w w. j a va 2s .c o m while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); } return sb.toString(); }
From source file:Main.java
public static String dumpBytesAsString(byte[] data) { final StringBuilder stringBuilder = new StringBuilder(data.length); for (byte byteChar : data) { stringBuilder.append(String.format("%02X ", byteChar)); }/*from www . j a v a2 s. co m*/ return stringBuilder.toString(); }
From source file:de.thischwa.pmcms.tool.Utils.java
/** * Joins variable numbers of string.//from w ww . j a v a2 s .com * * @param strings * @return joined string */ public static String join(String... strings) { StringBuilder sb = new StringBuilder(); for (String string : strings) sb.append(string); return sb.toString(); }
From source file:Main.java
public static String addQuote(String value) { StringBuilder str = new StringBuilder(); if (null == value) { return null; }//from w w w . j ava2s . co m str.append("\'").append(value).append("\'"); return str.toString(); }
From source file:Main.java
public static String removeDesiredDigit(String numStr, char digit) { StringBuilder builder = new StringBuilder(); for (char c : numStr.toCharArray()) { if (c != digit) { builder.append(c);/*w w w . j av a 2 s. c om*/ } } return builder.toString(); }
From source file:android.databinding.tool.util.ParserHelper.java
public static String toClassName(String name) { StringBuilder builder = new StringBuilder(); for (String item : name.split("[_-]")) { builder.append(StringUtils.capitalize(item)); }/* www.ja v a 2s. c o m*/ return builder.toString(); }
From source file:lux.xml.QName.java
/** * @param localPart the local part of the QName to encode * @param namespaceURI the namespace (URI) of the QName to encode (may be null) * @return the QName encoded in a suitable form for indexing. The namespace uri, if any, * is wrapped in {} and appended to the local-name. *///from w w w . j a v a 2 s .com public static String encode(String localPart, String namespaceURI) { if (StringUtils.isEmpty(namespaceURI)) { return localPart; } StringBuilder buf = new StringBuilder(); buf.append(localPart).append('{').append(namespaceURI).append("}"); return buf.toString(); }
From source file:Main.java
final public static String encodeToHex(int color) { StringBuilder builder = new StringBuilder(); if ((color & 0xFF) < 0x10) { builder.append("0"); }/*from w w w .j a va 2 s . c o m*/ builder.append(Long.toHexString(color)); return builder.toString(); }