Here you can find the source of inputStream2String(InputStream in)
public static String inputStream2String(InputStream in) throws UnsupportedEncodingException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; public class Main { public static String inputStream2String(InputStream in) throws UnsupportedEncodingException { BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8")); StringBuffer sb = new StringBuffer(); String line = null;/*from www.j a v a2 s . com*/ try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } return sb.toString(); } }