Here you can find the source of inputStreamToString(InputStream in)
public static String inputStreamToString(InputStream in) throws IOException
//package com.java2s; /*//from w ww .j a v a 2 s . c om * Copyright (C) 2012 mods.de community * * Everyone is permitted to copy and distribute verbatim or modified * copies of this software, and changing it is allowed as long as the * name is changed. * * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION * * 0. You just DO WHAT THE FUCK YOU WANT TO. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String inputStreamToString(InputStream in) throws IOException { BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(in)); StringBuilder stringBuilder = new StringBuilder(); String line = null; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line + "\n"); } bufferedReader.close(); return stringBuilder.toString(); } }