List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:Main.java
public static String byteToHex(byte data) { StringBuffer buf = new StringBuffer(); buf.append(toHexChar((data >>> 4) & 0x0F)); buf.append(toHexChar(data & 0x0F)); return buf.toString(); }
From source file:Main.java
public static String toString(Reader reader) throws IOException { int charValue; StringBuffer sb = new StringBuffer(1024); while ((charValue = reader.read()) != -1) { sb.append((char) charValue); }/*from ww w .ja v a 2s. c o m*/ return sb.toString(); }
From source file:Main.java
public static String readerToString(Reader r) throws Exception { //Read into string StringBuffer buff = new StringBuffer(); int c;// w w w .j a va 2 s .co m while ((c = r.read()) != -1) { buff.append((char) c); } return buff.toString(); }
From source file:Main.java
public static String bytesToHexes(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; }// w w w . ja v a2s . com StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { sb.append(byteToHexDigits(bytes[i])); } return sb.toString(); }
From source file:Main.java
public static String readTestFile(String file) { try {/*from w w w . java2s . co m*/ BufferedReader r = new BufferedReader(new FileReader(new File("test_data/" + file))); StringBuffer sb = new StringBuffer(); String s = null; while ((s = r.readLine()) != null) sb.append(s); return sb.toString(); } catch (Exception e) { e.printStackTrace(); return ""; } }
From source file:com.zb.app.common.util.SerialNumGenerator.java
private static String getSuffix(Long id) { Long num = 1l;/*from w w w . j a va2 s. c o m*/ Random random = new Random(); if (id != null) { num = id * (random.nextInt(1000)); if (num < 100) { num = num * (random.nextInt()); } num = (id * (random.nextInt(1000))) % 100000;// id?? } StringBuffer suffixBuffer = new StringBuffer(); suffixBuffer.append(String.valueOf(num)).append(random.nextInt(1000)); return StringUtils.leftPad(suffixBuffer.toString(), 8, '0'); }
From source file:PassPhrase.java
public static String getNext() { StringBuffer sb = new StringBuffer(); for (int i = 0; i < MIN_LENGTH; i++) { sb.append(goodChar[r.nextInt(goodChar.length)]); }//from www . ja v a 2s . co m return sb.toString(); }
From source file:Main.java
public static String generateRandomUTDID() { StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < 24; i++) { stringBuffer.append((char) (random.nextInt(25) + 65)); }/* w w w. j a v a 2 s . co m*/ return stringBuffer.toString(); }
From source file:Main.java
/** * @param uid// w ww. j ava2s.com * @return */ public static String getUserUid(int uid) { String uidStr = String.valueOf(uid); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 6 - uidStr.length(); i++) { sb.append("0"); } sb.append(uidStr); return sb.toString(); }
From source file:Main.java
public static String inputStream2String(InputStream is) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(is)); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null) { buffer.append(line);//from w w w . j a v a 2 s . c om } return buffer.toString(); }