Here you can find the source of inputStreamtoStream(InputStream in)
private static String inputStreamtoStream(InputStream in) throws UnsupportedEncodingException, IOException
//package com.java2s; /*//from w w w . j a v a2s . c o m * Creative Commons License: Attribution-ShareAlike 4.0 International * https://creativecommons.org/licenses/by-sa/4.0/legalcode */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; public class Main { private static String inputStreamtoStream(InputStream in) throws UnsupportedEncodingException, IOException { StringBuilder sb = new StringBuilder(); InputStreamReader is = new InputStreamReader(in, "UTF-8"); BufferedReader br = new BufferedReader(is); String read = br.readLine(); while (read != null) { sb.append(read); read = br.readLine(); } return sb.toString(); } }