Android InputStream to String Convert convert(InputStream is)

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

Description

convert

Declaration

public static String convert(InputStream is) 

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 convert(InputStream is) {
        BufferedReader r = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();
        String line;/*from   w w w  . j a v  a2 s.  c o m*/
        try {
            while ((line = r.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
}

Related

  1. convertStreamToText(InputStream is)
  2. convertStreamToText(InputStream is)
  3. convertToString(InputStream is, String encoding)
  4. convertToString(InputStream is, String encoding)
  5. convertToString(InputStream is, String encoding)
  6. readInputStream(InputStream inStream)
  7. toString(InputStream is)
  8. toStringBuffer(InputStream is)
  9. inputStream2String(InputStream in)