Java InputStream to String inputStream2String(InputStream is)

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

Description

input Stream String

License

Apache License

Declaration

public static String inputStream2String(InputStream is)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {

    public static String inputStream2String(InputStream is)
            throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int i = -1;
        while ((i = is.read()) != -1) {
            baos.write(i);//ww  w  .  j av  a  2 s  .  co  m
        }
        byte[] lens = baos.toByteArray();
        String result = new String(lens, "UTF-8");
        return result;
    }
}

Related

  1. inputStream2String(InputStream inputstream)
  2. inputStream2String(InputStream inStream)
  3. inputStream2String(InputStream is)
  4. inputStream2String(InputStream is)
  5. inputStream2String(InputStream is)
  6. inputStream2String(InputStream source)
  7. inputstream_to_string(InputStream in)
  8. inputStreamAsString(InputStream is)
  9. inputStreamReaderToStringBuilder(InputStreamReader reader, StringBuilder builder)