Java InputStream to String inputStreamToString(InputStream inputStream)

Here you can find the source of inputStreamToString(InputStream inputStream)

Description

input Stream To String

License

Open Source License

Declaration

static String inputStreamToString(InputStream inputStream) 

Method Source Code


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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    private static final int BUFFER_SIZE = 8192;

    static String inputStreamToString(InputStream inputStream) {
        StringBuilder sb = new StringBuilder(BUFFER_SIZE);
        try {/*ww  w  .  ja va2  s . co m*/
            BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
            String str = null;
            while ((str = r.readLine()) != null) {
                sb.append(str);
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
        return sb.toString();
    }
}

Related

  1. inputStreamToString(InputStream inputStream)
  2. InputStreamToString(InputStream inputStream)
  3. inputStreamToString(InputStream inputStream)
  4. inputStreamToString(InputStream inputStream)
  5. InputStreamToString(InputStream inputStream)
  6. inputStreamToString(InputStream inputStream)
  7. inputStreamToString(InputStream inputStream, String charsetName)
  8. inputStreamToString(InputStream is)
  9. inputStreamToString(InputStream is)