Here you can find the source of getInputStreamContent(InputStream inputStream)
Parameter | Description |
---|---|
inputStream | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String getInputStreamContent(InputStream inputStream) throws IOException
//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 char NL = '\n'; /**//from www . j av a 2 s . c o m * Get InputStream to String * * @param inputStream * @return String input value as string * @throws IOException */ public static String getInputStreamContent(InputStream inputStream) throws IOException { BufferedReader bufferReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuffer result = new StringBuffer(); String line; while ((line = bufferReader.readLine()) != null) { result.append(line).append(NL); } bufferReader.close(); return result.toString(); } }