List of usage examples for java.lang StringBuilder toString
@Override
@HotSpotIntrinsicCandidate
public String toString()
From source file:Main.java
private static String getLogInfoByArray(String[] infos) { StringBuilder sb = new StringBuilder(); for (String info : infos) { sb.append(info);//from w ww . ja v a 2 s . c o m sb.append(" "); } return sb.toString(); }
From source file:Main.java
public static String ByteArraytoHex(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("%02X ", b)); }//from w w w . j av a 2 s . c om return sb.toString(); }
From source file:Main.java
public static String readAssertsTextContent(Context context, String filename) { InputStream is = null;//ww w .j av a 2 s .c o m try { is = context.getResources().getAssets().open(filename); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); while (reader.ready()) sb.append(reader.readLine()); return sb.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; }
From source file:Main.java
public static String readerToString(final Reader r) throws Exception { // Read into string StringBuilder buff = new StringBuilder(); int c;//from w ww . ja v a 2 s.c om while ((c = r.read()) != -1) { buff.append((char) c); } return buff.toString(); }
From source file:Main.java
public static String getResponse(InputStream is) throws IOException { String nextLine;//from w ww. j a v a 2 s. c om InputStreamReader isr = new InputStreamReader(is, "UTF-8"); BufferedReader bf = new BufferedReader(isr); StringBuilder response = new StringBuilder(); while ((nextLine = bf.readLine()) != null) { response.append(nextLine); } return response.toString(); }
From source file:Main.java
public static String _byteArrayToHex(byte[] a) { StringBuilder sb = new StringBuilder(); for (byte b : a) sb.append(String.format("%02x-", b & 0xff)); sb.deleteCharAt(sb.length() - 1);/*from w ww . java 2 s . com*/ return sb.toString(); }
From source file:io.cortical.services.RetinaApiUtils.java
/** * Generate the base path for the retina. * /*from w w w. j a v a 2s. c om*/ * @param ip : retina server ip. * @param port : retina service port. * @return : the retina's API base path. */ public static String generateBasepath(final String ip, Short port) { if (isEmpty(ip)) { throw new IllegalArgumentException(NULL_SERVER_IP_MSG); } if (port == null) { port = 80; } StringBuilder basePath = new StringBuilder(); basePath.append("http://").append(ip).append(":").append(port).append("/rest"); return basePath.toString(); }
From source file:Main.java
public static String getHexText(byte[] mdByte) { int len = mdByte.length; StringBuilder sb = new StringBuilder(len * 2); for (int i = 0; i < len; i++) { sb.append(HEX_DIGITS[(mdByte[i] >> 4) & 0x0f]); }/*from w w w.j a v a 2 s . c o m*/ return sb.toString(); }
From source file:Main.java
private static String nZeros(int n) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) sb.append('0'); return sb.toString(); }
From source file:Main.java
public static void buildLink(TextView view, String url) { Log.d(TAG, "buildLink(view = " + view + ", url = " + url + ")"); StringBuilder sb = new StringBuilder(); sb.append("<a href='").append(url).append("'>").append(view.getText()).append("</a>"); view.setText(Html.fromHtml(sb.toString())); view.setMovementMethod(LinkMovementMethod.getInstance()); }