Android InputStream Read dealResponseResult(InputStream in)

Here you can find the source of dealResponseResult(InputStream in)

Description

deal Response Result

Declaration

public static String dealResponseResult(InputStream in) 

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 {
    private static final String CHARSET = "utf-8";

    public static String dealResponseResult(InputStream in) {
        try {/*from   w  w  w  . j  a  v  a  2 s . co  m*/
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(in, CHARSET));
            StringBuilder sb = new StringBuilder();
            String msg = null;
            while ((msg = reader.readLine()) != null) {
                sb.append(msg);
            }
            return sb.toString();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {

            try {
                if (in != null) {
                    in.close();
                }

            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

Related

  1. readShort(InputStream stream)
  2. readStringFromInputStream(InputStream is)
  3. readTextInputStream(InputStream is)
  4. readData(InputStream inSream, String charsetName)
  5. skip(InputStream stream, int numBytes)
  6. getInputStreamFromUrl_V9( Context paramContext, String paramString)
  7. getResponseBody(InputStream inputStream)
  8. makeInputStream(Uri uri, ContentResolver cr)
  9. outputFile(InputStream is, String targetPath, String filename)