Java InputStream to String inputStream2String(InputStream inStream)

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

Description

input Stream String

License

Open Source License

Declaration

public static final String inputStream2String(InputStream inStream)
        throws IOException 

Method Source Code

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

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

public class Main {

    public static final String inputStream2String(InputStream inStream)
            throws IOException {
        return new String(inputStream2byte(inStream));
    }// w w w  .j  a v a 2s.  c o  m

    public static final byte[] inputStream2byte(InputStream inStream)
            throws IOException {
        ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
        byte[] buff = new byte[100];
        int rc = 0;
        while ((rc = inStream.read(buff, 0, 100)) > 0) {
            swapStream.write(buff, 0, rc);
        }
        byte[] in2b = swapStream.toByteArray();
        return in2b;
    }
}

Related

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