Android InputStream to String Convert inputStream2String(InputStream in)

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

Description

InputStream convert to string

License

Open Source License

Parameter

Parameter Description
in a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static String inputStream2String(InputStream in)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InputStream;

public class Main {
    /**/*  w  w  w.  j a va  2  s.c  o  m*/
     * InputStream convert to string
     *
     * @param in
     * @return
     * @throws IOException
     */
    public static String inputStream2String(InputStream in)
            throws IOException {
        StringBuffer out = new StringBuffer();
        byte[] b = new byte[4096];
        for (int n; (n = in.read(b)) != -1;) {
            out.append(new String(b, 0, n));
        }
        return out.toString();
    }
}

Related

  1. convertToString(InputStream is, String encoding)
  2. convert(InputStream is)
  3. readInputStream(InputStream inStream)
  4. toString(InputStream is)
  5. toStringBuffer(InputStream is)
  6. inputStreamToString(InputStream in)
  7. inputStreamToString(InputStream is)
  8. InputStreamToString(InputStream stream)
  9. convertInputStreamToString(InputStream inputStream)