Here you can find the source of readIt(InputStream stream)
Parameter | Description |
---|---|
stream | The InputStream |
Parameter | Description |
---|---|
IOException | If reading fails |
private static String readIt(InputStream stream) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /**// www .ja va 2 s . co m * Reads an InputStream as an UTF-8 string * * @param stream * The InputStream * @return * The read string * @throws IOException * If reading fails */ private static String readIt(InputStream stream) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(stream)); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } }