Here you can find the source of readStringFromInputStream(InputStream is)
public static String readStringFromInputStream(InputStream is) throws IOException
//package com.java2s; /* //from w ww . j a va 2 s . co m * SWRVE CONFIDENTIAL * * (c) Copyright 2010-2014 Swrve New Media, Inc. and its licensors. * All Rights Reserved. * * NOTICE: All information contained herein is and remains the property of Swrve * New Media, Inc or its licensors. The intellectual property and technical * concepts contained herein are proprietary to Swrve New Media, Inc. or its * licensors and are protected by trade secret and/or copyright law. * Dissemination of this information or reproduction of this material is * strictly forbidden unless prior written permission is obtained from Swrve. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readStringFromInputStream(InputStream is) throws IOException { BufferedReader rd = new BufferedReader(new InputStreamReader(is)); StringBuilder body = new StringBuilder(); String line; while ((line = rd.readLine()) != null) { body.append(line); } return body.toString(); } }