List of utility methods to do InputStream to String Convert
String | inputStreamToString(InputStream stream) input Stream To String try { BufferedReader reader = new BufferedReader( new InputStreamReader(stream), 8192); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { if (line.trim().length() > 0) { sb.append(line); ... |
String | streamToString(InputStream in, String charset) stream To String try { BufferedReader reader = new BufferedReader( new InputStreamReader(in, charset)); StringBuffer buffer = new StringBuffer(); String line = null; try { while ((line = reader.readLine()) != null) { buffer.append(line); ... |
String | InputStreamToString(InputStream in) Input Stream To String ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] data = new byte[BUFFER_SIZE]; int count = -1; while ((count = in.read(data, 0, BUFFER_SIZE)) != -1) { outStream.write(data, 0, count); data = null; return new String(outStream.toByteArray(), "ISO-8859-1"); ... |
String | inputToString(InputStream inputStream, String encoding) input To String ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len = 0; while ((len = inputStream.read(buffer)) != -1) { bos.write(buffer, 0, len); inputStream.close(); bos.close(); ... |
String | converStreamToString(InputStream is) conver Stream To String BufferedReader reader = new BufferedReader( new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line); } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); return sb.toString(); |
String | inputStreamToString(InputStream inputStream) input Stream To String BufferedReader in = new BufferedReader(new InputStreamReader( inputStream), BUFFER_SIZE); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null) { buffer.append(line); return buffer.toString(); ... |
String | streamToString(InputStream is) Reads a InputStream into a String if (is != null) { StringBuilder sb = new StringBuilder(); String line; try { InputStreamReader inputStreamReader = new InputStreamReader( is, "utf-8"); BufferedReader reader = new BufferedReader( inputStreamReader); ... |
String | slurp(InputStream in) slurp StringBuffer out = new StringBuffer(); byte[] b = new byte[4096]; try { for (int n; (n = in.read(b)) != -1;) { out.append(new String(b, 0, n)); } catch (IOException e) { e.printStackTrace(); ... |
String | convertStreamToString(InputStream is) Convert an InputStream to String BufferedReader reader = new BufferedReader( new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line).append("\n"); reader.close(); ... |
String | inStream2Str(InputStream inputStream, String encode) in Stream Str String result = null; if (inputStream != null) { try { BufferedInputStream bis = new BufferedInputStream( inputStream); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int position = 0; while ((position = bis.read()) != -1) { ... |