List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:Main.java
/** * Replaces successive XML space characters (<tt>'\t'</tt>, * <tt>'\r'</tt>, <tt>'\n'</tt>, <tt>' '</tt>) by a single space * character (<tt>' '</tt>). * // ww w. java 2s . co m * @param value string to be processed * @return processed string */ public static final String compressWhiteSpace(String value) { StringBuffer buffer = new StringBuffer(); compressWhiteSpace(value, buffer); return buffer.toString(); }
From source file:Main.java
public static String addSetString(String fieldName) { if (fieldName.startsWith("is")) { return fieldName.replace("is", "set"); }//ww w. j a v a2s .com StringBuffer sb = new StringBuffer(); sb.append("set"); sb.append(fieldName.substring(0, 1).toUpperCase()); sb.append(fieldName.substring(1)); return sb.toString(); }
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 ww .j a v a 2 s . c o m*/ } return (buf.toString()); }
From source file:Main.java
private static String readFirstLine(InputStreamReader rdr) throws IOException { char[] buf = new char[1]; StringBuffer bldr = new StringBuffer(); rdr.read(buf);//w w w .j ava2 s.c o m while (buf[0] != '>') { bldr.append(buf[0]); rdr.read(buf); } return bldr.toString(); }
From source file:Replace.java
public static String replace(String oldStr, String newStr, String inString) { int start = inString.indexOf(oldStr); if (start == -1) { return inString; }//from w w w . j av a 2s . c o m StringBuffer sb = new StringBuffer(); sb.append(inString.substring(0, start)); sb.append(newStr); sb.append(inString.substring(start + oldStr.length())); return sb.toString(); }
From source file:Main.java
public static String formatNumber(int number, int length) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { sb.append("0"); }/*ww w . j a va2 s .c o m*/ java.text.DecimalFormat format = new java.text.DecimalFormat(sb.toString()); return format.format(number); }
From source file:Main.java
public static String toHexString(final byte[] src) { StringBuffer buf = new StringBuffer(); for (byte b : src) { String s = String.format("%02x", b & 0xff); buf.append(s).append(","); }/* www. j a va 2 s . co m*/ return buf.toString(); }
From source file:Main.java
/** * Transforms a byte array in a hex string * /*from w w w . j ava 2s. c o m*/ * @param digest * Digest * @return Display ready string */ public static String ToHexString(byte[] digest) { StringBuffer hexStr = new StringBuffer(40); for (byte b : digest) { hexStr.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1)); } return hexStr.toString(); }
From source file:Main.java
public static String getColumnId(int column) { Stack<Character> digits = new Stack<Character>(); int dividant = column; while (dividant > 26) { int remain = dividant % 26; dividant = dividant / 26;/*from www . j a v a 2s .c o m*/ if (remain == 0) { remain = 26; dividant--; } digits.push((char) ('A' + remain - 1)); } digits.push((char) ('A' + dividant - 1)); StringBuffer buffer = new StringBuffer(); while (!digits.empty()) { buffer.append(digits.pop()); } String columnId = buffer.toString(); return columnId; }
From source file:Main.java
public static String inputStream2String(InputStream in) throws IOException { BufferedReader inReader = new BufferedReader(new InputStreamReader(in)); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = inReader.readLine()) != null) { buffer.append(line);/*from ww w. j a v a 2 s . c o m*/ } return buffer.toString(); }