Here you can find the source of getInputStreamAsString(InputStream stream)
public static String getInputStreamAsString(InputStream stream) throws IOException
//package com.java2s; /**//from w ww . j a v a 2s .c om * Copyright (c) 2011, 2014 Eurotech and/or its affiliates * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eurotech */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String getInputStreamAsString(InputStream stream) throws IOException { StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(stream)); char[] cbuf = new char[1024]; int len; while ((len = br.read(cbuf)) > 0) { sb.append(cbuf, 0, len); } } finally { if (br != null) br.close(); } return sb.toString(); } }