Java examples for java.io:InputStream Read
Converts an Input Stream to a String
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /**//from ww w . ja v a 2s .c om * Converts an Input Stream to a String * * @param stream * @return * @throws java.io.IOException */ public static String inputStreamToString(InputStream stream) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader( stream)); StringBuilder builder = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { builder.append(line); builder.append("\n"); } reader.close(); stream.close(); return builder.toString(); } }