Java InputStream to String inputStreamToString(InputStream inputStream, String charsetName)

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

Description

input Stream To String

License

Open Source License

Declaration

public static String inputStreamToString(InputStream inputStream, String charsetName) throws IOException 

Method Source Code

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

import java.io.*;

public class Main {
    public static String inputStreamToString(InputStream inputStream, String charsetName) throws IOException {
        StringBuilder builder = new StringBuilder();
        InputStreamReader reader = new InputStreamReader(inputStream, charsetName);
        char[] buffer = new char[4 * 1024];
        int length;
        while ((length = reader.read(buffer)) != -1) {
            builder.append(buffer, 0, length);
        }//from  w  ww  . j  a v a2  s. com
        return builder.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 is)
  7. inputStreamToString(InputStream is)
  8. inputStreamToString(InputStream is)
  9. inputStreamToString(InputStream is)