Here you can find the source of inputStreamToString(InputStream in)
Parameter | Description |
---|---|
in | InputStream |
Parameter | Description |
---|---|
Exception | an exception |
public static String inputStreamToString(InputStream in) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /**//from w ww . ja v a 2 s . co m * read a String from an InputStream object. * @param in InputStream * @return String * @throws Exception */ public static String inputStreamToString(InputStream in) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(in)); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = br.readLine()) != null) { buffer.append(line); } return buffer.toString(); } }