Write code to read InputStream via BufferedReader
//package com.book2s; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /**/*from w w w. java2 s . co m*/ * change the content to a string. * * @param file * @return the content of file. */ public static final String fileInputStream2String(InputStream is) { BufferedReader br; StringBuilder strBlder = new StringBuilder(""); try { br = new BufferedReader(new InputStreamReader(is)); String line = ""; while (null != (line = br.readLine())) { strBlder.append(line + "\n"); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return strBlder.toString(); } }