List of usage examples for java.lang StringBuilder toString
@Override
@HotSpotIntrinsicCandidate
public String toString()
From source file:Main.java
static String readAllOf(InputStream s) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(s), 8096); String line;/*from w ww.j a v a2 s. co m*/ StringBuilder log = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { log.append(line); log.append("\n"); } return log.toString(); }
From source file:Main.java
public static String stringGetMD5String(String s) { byte[] data;//from w w w . j av a 2s . co m MessageDigest md5; try { data = s.getBytes("UTF-8"); md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { return null; } byte[] hash = md5.digest(data); StringBuilder hashStr = new StringBuilder(); for (byte byteValue : hash) { hashStr.append(String.format("%02x", byteValue)); } return hashStr.toString(); }
From source file:Main.java
public static String toUpperString(String s) { int idx = 0;//from w ww . j ava 2s . co m for (; idx < s.length(); idx++) { char c = s.charAt(idx); if (c >= 'a' && c <= 'z') { break; } } if (idx == s.length()) { return s; } StringBuilder buf = new StringBuilder(s.substring(0, idx)); for (; idx < s.length(); idx++) { buf.append(toUpper(s.charAt(idx))); } return buf.toString(); }
From source file:Main.java
public static String toLowerString(String s) { int idx = 0;//from w w w.j a v a 2 s .c om for (; idx < s.length(); idx++) { char c = s.charAt(idx); if (c >= 'A' && c <= 'Z') { break; } } if (idx == s.length()) { return s; } StringBuilder buf = new StringBuilder(s.substring(0, idx)); for (; idx < s.length(); idx++) { buf.append(toLower(s.charAt(idx))); } return buf.toString(); }
From source file:Main.java
public static String getStringFromFile(final String filePath, final Context context) throws IOException { final FileInputStream in = context.openFileInput(filePath); final InputStreamReader inputStreamReader = new InputStreamReader(in); final BufferedReader bufferedReader = new BufferedReader(inputStreamReader); final StringBuilder sb = new StringBuilder(); String line;/*from w w w .j av a2s . c o m*/ while ((line = bufferedReader.readLine()) != null) { sb.append(line); } return sb.toString(); }
From source file:com.dtolabs.rundeck.core.utils.OptsUtil.java
public static String escapeChars(String str) { StringBuilder stringBuilder = new StringBuilder(); escapeChars(stringBuilder, str);/* w w w. j av a 2 s. com*/ return stringBuilder.toString(); }
From source file:Main.java
/** * Reads all text up to next XML tag and returns it as a String. * * @return the String of the text read, which may be empty. */// w ww. ja v a 2 s .co m public static String readUntilTag(Reader r) throws IOException { if (!r.ready()) { return ""; } StringBuilder b = new StringBuilder(); int c = r.read(); while (c >= 0 && c != '<') { b.append((char) c); c = r.read(); } return b.toString(); }
From source file:Main.java
/** * Converts an array of bits (represented with integers) to an integer. * * This method is mainly used to decode the margin of an encoded image. * * @param binaryList An array of integers which represents a number in binary format * @return The converted integer// w ww.j a v a 2 s . c o m */ public static int getIntegerBinaryList(ArrayList<Integer> binaryList) { StringBuilder binaryString = new StringBuilder(); for (Integer currentBit : binaryList) { binaryString.append(currentBit); } return Integer.parseInt(binaryString.toString(), 2); }
From source file:Main.java
public static String join(Iterator<String> strings, String sep) { if (!strings.hasNext()) return ""; String start = strings.next(); if (!strings.hasNext()) // only one, avoid builder return start; StringBuilder sb = new StringBuilder(64).append(start); while (strings.hasNext()) { sb.append(sep);//w w w. j av a 2s . c o m sb.append(strings.next()); } return sb.toString(); }
From source file:Main.java
public static String headerString(TableColumn tc) { final StringBuilder result = new StringBuilder(); result.append(tc.getHeaderValue());/*from ww w. j a v a2s . c om*/ result.append('[').append(tc.getPreferredWidth()).append(']'); return result.toString(); }