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) 

Method Source Code


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

import java.io.*;

public class Main {
    public static String inputStream2String(InputStream is) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int i = -1;
        try {/*from ww  w. j a v  a 2s  .com*/
            while ((i = is.read()) != -1) {
                baos.write(i);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return baos.toString();
    }
}

Related

  1. inputStream2String(InputStream in)
  2. InputStream2String(InputStream in, String encoding)
  3. InputStream2String(InputStream in_st, String charset)
  4. inputStream2String(InputStream inputstream)
  5. inputStream2String(InputStream inStream)
  6. inputStream2String(InputStream is)
  7. inputStream2String(InputStream is)
  8. inputStream2String(InputStream is)
  9. inputStream2String(InputStream source)