Android InputStream Read readData(InputStream inSream, String charsetName)

Here you can find the source of readData(InputStream inSream, String charsetName)

Description

read Data

Declaration

public static String readData(InputStream inSream, String charsetName)
            throws IOException 

Method Source Code

//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static String readData(InputStream inSream, String charsetName)
            throws IOException {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = -1;
        while ((len = inSream.read(buffer)) != -1) {
            outStream.write(buffer, 0, len);
        }/*from w  ww. j av a  2  s.  com*/
        byte[] data = outStream.toByteArray();
        outStream.close();
        inSream.close();
        return new String(data, charsetName);
    }
}

Related

  1. readInt(InputStream stream)
  2. readLong(InputStream in, final int fitInBytes)
  3. readShort(InputStream stream)
  4. readStringFromInputStream(InputStream is)
  5. readTextInputStream(InputStream is)
  6. skip(InputStream stream, int numBytes)
  7. dealResponseResult(InputStream in)
  8. getInputStreamFromUrl_V9( Context paramContext, String paramString)
  9. getResponseBody(InputStream inputStream)