Java InputStream to String InputStreamToString(InputStream input_stream)

Here you can find the source of InputStreamToString(InputStream input_stream)

Description

Input Stream To String

License

Open Source License

Declaration

public static String InputStreamToString(InputStream input_stream) throws Exception 

Method Source Code


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

import java.io.BufferedReader;

import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String InputStreamToString(InputStream input_stream) throws Exception {
        StringBuilder sb = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(input_stream, "UTF-8"));

        String sBuffer = br.readLine();
        while (sBuffer != null) {
            sb.append(sBuffer);//from   w  w w.  ja v a  2 s . c  o m
            sb.append(System.lineSeparator());
            sBuffer = br.readLine();
        }

        return sb.toString();
    }
}

Related

  1. InputStreamToString(InputStream in)
  2. InputStreamTOString(InputStream in)
  3. InputStreamToString(InputStream in, String charset)
  4. InputStreamTOString(InputStream in, String encoding)
  5. inputStreamToString(InputStream input)
  6. inputStreamToString(InputStream inputStream)
  7. InputStreamToString(InputStream inputStream)
  8. inputStreamToString(InputStream inputStream)
  9. inputStreamToString(InputStream inputStream)