Here you can find the source of inputStreamToString(InputStream inputStream)
Parameter | Description |
---|---|
inputStream | the input stream |
public static String inputStreamToString(InputStream inputStream)
//package com.java2s; /*/*from w w w. j a v a2s . co m*/ * dataZ - Test Support For Data Stores. * * Copyright 2014-2017 the original author or authors. * * 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 */ import java.io.*; public class Main { /** * Converts the {@code inputStream} to String. The {@code inputStream} will be consumed. * * @param inputStream the input stream * @return the content as string. */ public static String inputStreamToString(InputStream inputStream) { final StringBuilder output = new StringBuilder(); try (final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { String line; while (null != (line = reader.readLine())) { output.append(line).append('\n'); } } catch (IOException ex) { throw new RuntimeException("Caught IO Exception", ex); } return output.toString(); } }