Here you can find the source of getInputStreamAsString(final InputStream is, final String encoding)
public static String getInputStreamAsString(final InputStream is, final String encoding)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * 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://from w ww. j av a 2 s . c o m * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.InputStream; import java.util.Scanner; public class Main { public static String getInputStreamAsString(final InputStream is, final String encoding) { final Scanner s = new Scanner(is, encoding).useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; } }