List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:Main.java
public static String toTitleCase(String givenString) { if (givenString.length() > 0) { String[] arr = givenString.split(" "); StringBuffer sb = new StringBuffer(); for (int i = 0; i < arr.length; i++) { sb.append(Character.toUpperCase(arr[i].charAt(0))).append(arr[i].substring(1)).append(" "); }/*from w ww . j a va 2 s . c o m*/ return sb.toString().trim(); } return ""; }
From source file:Main.java
static String removeJunk(String string) { int i, len = string.length(); StringBuffer dest = new StringBuffer(len); char c;/*w w w . j av a 2 s.co m*/ for (i = (len - 1); i >= 0; i--) { c = string.charAt(i); if (Character.isLetterOrDigit(c)) { dest.append(c); } } return dest.toString(); }
From source file:Main.java
public static String joinSelectionCriteria(List<String> input) { if (input.size() == 0) { return null; }/*from ww w .j ava2 s. c om*/ StringBuffer sb = new StringBuffer(); for (int i = 0; i < input.size(); i++) { if (i > 0) { sb.append(" AND "); } sb.append(input.get(i)); } return sb.toString(); }
From source file:Main.java
public static String readRawByName(Context context, int id, String encoding) { String text = ""; InputStreamReader inputReader = null; BufferedReader bufReader = null; try {/*from w w w .ja v a2 s .c o m*/ inputReader = new InputStreamReader(context.getResources().openRawResource(id)); bufReader = new BufferedReader(inputReader); String line = null; StringBuffer buffer = new StringBuffer(); while ((line = bufReader.readLine()) != null) { buffer.append(line); } text = new String(buffer.toString().getBytes(), encoding); } catch (Exception e) { e.printStackTrace(); } finally { try { if (bufReader != null) { bufReader.close(); bufReader = null; } if (inputReader != null) { inputReader.close(); inputReader = null; } } catch (Exception e) { e.printStackTrace(); } } return text; }
From source file:Main.java
public static String join(Object... objs) { if (objs == null) return ""; StringBuffer s = new StringBuffer(); for (int i = 0, n = objs.length; i < n; i++) { s.append(objs[i]);//from ww w.j ava 2s . c o m if (i != n - 1) s.append(","); } return s.toString(); }
From source file:Main.java
public static String join(int[] objs) { if (objs == null) return ""; StringBuffer s = new StringBuffer(); for (int i = 0, n = objs.length; i < n; i++) { s.append(objs[i]);/*from w ww. jav a 2 s .com*/ if (i != n - 1) s.append(","); } return s.toString(); }
From source file:Main.java
public static String join(long[] objs) { if (objs == null) return ""; StringBuffer s = new StringBuffer(); for (int i = 0, n = objs.length; i < n; i++) { s.append(objs[i]);/*from w ww. ja v a2 s .co m*/ if (i != n - 1) s.append(","); } return s.toString(); }
From source file:Main.java
public static String toHex(byte[] to) { if (null == to || to.length == 0) return "[]"; StringBuffer sb = new StringBuffer("[" + Integer.toHexString(to[0] & 0xFF)); for (int i = 1; i < to.length; i++) { sb.append(String.format(" %02x", to[i] & 0xFF)); }//from w w w . j a va 2 s . c o m sb.append("]"); return sb.toString(); }
From source file:com.comcast.cdn.traffic_control.traffic_router.api.util.APIAccessRecord.java
private static String getUrl(final HttpServletRequest request) { final StringBuffer buf = request.getRequestURL(); if (request.getQueryString() != null) { buf.append('?'); buf.append(request.getQueryString()); }// www .ja v a 2 s . com return buf.toString(); }
From source file:corner.orm.tapestry.service.captcha.RandomUtil.java
/** * ???/*from ww w . j ava 2s.c o m*/ * @param string * @return ? */ public static String encodeStr(String string) { String str = DigestUtils.md5Hex(string); StringBuffer sb = new StringBuffer(); sb.append(str.charAt(7)); sb.append(str.charAt(15)); sb.append(str.charAt(23)); sb.append(str.charAt(31)); return sb.toString(); }