List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:com.mmj.app.common.util.SerialNumGenerator.java
private static String getSuffix(Long id) { Long num = 1l;//from w ww . jav a 2 s.c o m if (id != null) { num = id % 100000;// id?? } Random random = new Random(); StringBuffer suffixBuffer = new StringBuffer(); suffixBuffer.append(String.valueOf(num)).append(random.nextInt(1000)); return StringUtils.leftPad(suffixBuffer.toString(), 8, '0'); }
From source file:Main.java
/** * Return the very first line of an XML file. * Beware : the encoding used in xml is not the same as the one returned * by the java Writer's getEncoding methods. writeFirstLine take care of it * @see EncodingMap.getXMLFromJava(String) *//* w ww . j a v a 2 s. co m*/ public static String getFirstLine(String xmlEncoding) { StringBuffer sb = new StringBuffer(64); sb.append("<?xml version=\"1.0\" encoding=\""); sb.append(xmlEncoding); sb.append("\" standalone=\"yes\"?>"); return sb.toString(); }
From source file:Main.java
public static String inputStreamToString(InputStream in) throws Exception { StringBuffer out = new StringBuffer(); byte[] b = new byte[4096]; for (int n; (n = in.read(b)) != -1;) { out.append(new String(b, 0, n)); }/*from ww w. j av a 2 s. c om*/ return out.toString(); }
From source file:Main.java
public static String appendZeros(String binaryNum) { int len = binaryNum.length(); if (len % 7 == 0) { return binaryNum; } else {/*from w w w . j av a2 s. c o m*/ int remainingDiff = (len % 7); int diff = 7 - remainingDiff; StringBuffer sb = new StringBuffer(); for (int i = 0; i < diff; i++) { sb.append(0); } sb.append(binaryNum); return sb.toString(); } }
From source file:Main.java
private static void logInConsole(ArrayList<Integer> timePoints) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < timePoints.size(); i++) { sb.append(timePoints.get(i)).append(" "); }// w w w .ja v a2 s . com Log.d(TAG, sb.toString()); }
From source file:Main.java
public static String randomString(int length) { String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random random = new Random(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < length; i++) { int num = random.nextInt(62); buf.append(str.charAt(num));//from w w w .j a va 2s.c o m } return buf.toString(); }
From source file:Main.java
/** * Escapes characters that are not allowed in various places * in XML by replacing all invalid characters with * <code>getEscape(c)</code>. * // ww w . j av a 2 s . co m * @param in The <code>String</code> containing * the text to escape in place. */ public static String XMLEscape(String in) { if (in == null) { return null; } final StringBuffer temp = new StringBuffer(in); XMLEscape(temp); return temp.toString(); }
From source file:Main.java
public static String toHex(byte[] buf) { if (buf == null) return ""; StringBuffer result = new StringBuffer(2 * buf.length); for (byte aBuf : buf) { appendHex(result, aBuf);//from w w w . jav a 2s. co m } return result.toString(); }
From source file:Main.java
private static String toHex(byte[] buf) { if (buf == null) return ""; StringBuffer result = new StringBuffer(2 * buf.length); for (int i = 0; i < buf.length; i++) { appendHex(result, buf[i]);/*w w w . jav a 2s .c om*/ } return result.toString(); }
From source file:Main.java
public static String byteToPdu(int b) { StringBuffer sb = new StringBuffer(); String s = Integer.toHexString(b & 0xFF); if (s.length() == 1) { sb.append("0"); }//from w w w . j a v a 2 s . c o m sb.append(s); return sb.toString().toUpperCase(); }