Android InputStream to String Convert streamToString(InputStream is)

Here you can find the source of streamToString(InputStream is)

Description

stream To String

Declaration

public static String streamToString(InputStream is) throws IOException 

Method Source Code

//package com.java2s;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String streamToString(InputStream is) throws IOException {
        String str = "";

        if (is != null) {
            StringBuilder sb = new StringBuilder();
            String line;/*from   w  ww .ja v a2 s.  c o m*/

            try {
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(is));

                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                }

                reader.close();
            } finally {
                is.close();
            }

            str = sb.toString();
        }

        return str;
    }
}

Related

  1. fromStream(InputStream inputStream)
  2. parseString(InputStream is)
  3. convertStreamToString(InputStream is)
  4. readToString(final InputStream inputStream)
  5. inputStreamToString(InputStream inputstream)
  6. inputStreamToString(InputStream is)
  7. inputStreamToString(InputStream stream)
  8. streamToString(InputStream in, String charset)
  9. InputStreamToString(InputStream in)