Android InputStream to String Convert toConvertString(InputStream is)

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

Description

to Convert String

Declaration

public static String toConvertString(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 toConvertString(InputStream is) {
        StringBuffer res = new StringBuffer();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader read = new BufferedReader(isr);
        try {//from  ww w. ja va  2s. com
            String line;
            line = read.readLine();
            while (line != null) {
                res.append(line);
                line = read.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (null != isr) {
                    isr.close();
                    isr.close();
                }
                if (null != read) {
                    read.close();
                    read = null;
                }
                if (null != is) {
                    is.close();
                    is = null;
                }
            } catch (IOException e) {
            }
        }
        return res.toString();
    }
}

Related

  1. getString(InputStream is)
  2. inputStream2String(InputStream is)
  3. inputStream2String(InputStream in)
  4. stream2String(InputStream is, int maxLength)
  5. fromStream(InputStream stream)
  6. inStream2String(InputStream is)
  7. inputStream2String(InputStream is)
  8. inStream2String(InputStream is)
  9. fromStream(InputStream inputStream)