List of utility methods to do InputStream to String
String | getStreamAsString(InputStream is, String encoding) Copies the contents of the given stream to a string. Reader r = null; if (encoding == null) { r = new InputStreamReader(is); } else { r = new InputStreamReader(is, encoding); try { StringWriter w = new StringWriter(); ... |
String | getStreamAsString(InputStream stream) get Stream As String String output = ""; byte[] buffer = new byte[4096]; while (stream.read(buffer) > 0) { output = output + new String(buffer); return output; |
String | getStreamAsString(InputStream stream, String charset) get Stream As String try { BufferedReader reader = new BufferedReader(new InputStreamReader(stream, charset)); StringWriter writer = new StringWriter(); char[] chars = new char[256]; int count = 0; while ((count = reader.read(chars)) > 0) { writer.write(chars, 0, count); return writer.toString(); } finally { if (stream != null) { stream.close(); |
String | getStreamContent(InputStream is) get Stream Content BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String c = "", line; while ((line = reader.readLine()) != null) c += "\n" + line; return c.substring(1); |
byte[] | getStreamContent(InputStream stream, int bufferSize) get Stream Content ByteArrayOutputStream output = new ByteArrayOutputStream(); try { byte[] buffer = new byte[bufferSize]; int len = stream.read(buffer, 0, bufferSize); if (len > 0) { output.write(buffer, 0, len); } finally { ... |
String | getStreamContentAsString(InputStream is) Gets the stream content as string. try { byte buf[] = new byte[is.available()]; is.read(buf); return new String(buf, "UTF-8"); } catch (Exception e) { throw new RuntimeException(e); |
String | getStreamContentAsString(InputStream is, String encoding) get Stream Content As String return new String(getStreamContentAsBytes(is), encoding); |
String | getStreamContents(final InputStream is) get Stream Contents return getStreamContents(is, DEFAULT_ENCODING);
|
String | inputStream2String(InputStream in) input Stream String BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8")); StringBuffer sb = new StringBuffer(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } catch (IOException e) { ... |
String | inputStream2String(InputStream in) input Stream String StringBuffer out = new StringBuffer(); byte[] b = new byte[4096]; for (int n; (n = in.read(b)) != -1;) { out.append(new String(b, 0, n)); return out.toString(); |