Java examples for java.io:InputStream Read
read InputStream and return a String
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; public class Main { public static String readInput(InputStream in) throws IOException { InputStreamReader isr = new InputStreamReader(in); Reader reader = new BufferedReader(isr); StringBuilder s = new StringBuilder(); char buffer[] = new char[2048]; int size; while ((size = reader.read(buffer)) > 0) { s.append(buffer, 0, size);/* ww w .j a v a 2 s .c o m*/ } return s.toString(); } }