Java Utililty Methods InputStream to String

List of utility methods to do InputStream to String

Description

The list of methods to do InputStream to String are organized into topic(s).

Method

StringBuilderinputStreamToStringBuilder(final InputStream inputStream, final String charset)
Copies the stream into the string builder.
final InputStreamReader in;
if (charset == null || charset.trim().equals(""))
    in = new InputStreamReader(inputStream);
else
    in = new InputStreamReader(inputStream, charset);
final BufferedReader buf = new BufferedReader(in);
final StringBuilder sb = new StringBuilder();
String line = null;
...
StringBuilderinputStreamToStringBuilder(InputStream in, int minimumCapacity)
input Stream To String Builder
StringBuilder builder = new StringBuilder(minimumCapacity);
inputStreamToStringBuilder(in, builder);
return builder;
StringinputStreamToText(InputStream inputStream)
Converts a response in an InputStream to a String for easy comparisons
byte[] bytes = inputStreamToBytes(inputStream);
return new String(bytes);
StringloadText(InputStream in)
Loads the entire stream into memory as a String and returns it.
StringBuilder builder = new StringBuilder();
try (InputStreamReader isr = new InputStreamReader(in)) {
    BufferedReader reader = new BufferedReader(isr);
    while (true) {
        String line = reader.readLine();
        if (line != null) {
            builder.append(line);
            builder.append("\n");
...
StringloadTextFile(InputStream stream, String encoding, int maxSize, boolean finish)
Get the contents of the stream to a .self file and parse it.
if (encoding.trim().isEmpty()) {
    encoding = "UTF-8";
String UTF8_BOM = "\uFEFF";
StringWriter writer = new StringWriter();
InputStreamReader reader = null;
try {
    reader = new InputStreamReader(stream, encoding);
...
StringvalueOf(InputStream is)
value Of
try {
    int i = -1;
    byte[] b = new byte[1024 * 100];
    StringBuffer sb = new StringBuffer();
    while ((i = is.read(b)) != -1) {
        sb.append(new String(b, 0, i));
    String content = sb.toString();
...