Android InputStream to String Convert convertStreamToString(InputStream is)

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

Description

convert Stream To String

Declaration

public static String convertStreamToString(InputStream is) 

Method Source Code

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

public class Main {
    public static String convertStreamToString(InputStream is) {
        BufferedReader reader = null;
        try {//  w  ww .  j  a v  a  2 s  .c om
            reader = new BufferedReader(new InputStreamReader(is, "utf-8"),// "UTF-8"
                    512 * 1024);
        } catch (Exception e) {
        }
        StringBuilder sb = new StringBuilder();
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (Exception e) {
        } finally {
            try {
                is.close();
            } catch (Exception e) {
            }
        }
        return sb.toString();
    }
}

Related

  1. convertInputStreamToString(InputStream inputStream)
  2. convertStreamToString(InputStream inputStream)
  3. convertStreamToString(InputStream inputStream)
  4. convertStreamToString(InputStream is)
  5. convertStreamToString(InputStream is)
  6. convertStreamToString(InputStream is)
  7. convertStreamToString(InputStream is)
  8. convertStreamToString(InputStream is)
  9. convertStreamToString(InputStream is)