Android InputStream to String Convert slurp(InputStream in)

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

Description

slurp

Declaration

public static String slurp(InputStream in) 

Method Source Code

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

public class Main {
    public static String slurp(InputStream in) {
        StringBuffer out = new StringBuffer();
        byte[] b = new byte[4096];
        try {//w ww  .  j av a  2 s. co  m
            for (int n; (n = in.read(b)) != -1;) {
                out.append(new String(b, 0, n));
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return out.toString();
    }
}

Related

  1. InputStreamToString(InputStream in)
  2. inputToString(InputStream inputStream, String encoding)
  3. converStreamToString(InputStream is)
  4. inputStreamToString(InputStream inputStream)
  5. streamToString(InputStream is)
  6. convertStreamToString(InputStream is)
  7. inStream2Str(InputStream inputStream, String encode)
  8. readIt(InputStream stream)
  9. inputStream2String(InputStream inputStream)