Here you can find the source of readAll(InputStream input)
Parameter | Description |
---|---|
input | the stream to be read |
public static String readAll(InputStream input)
//package com.java2s; /*/* w w w.j a v a 2 s . co m*/ * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2004-2009, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /** * Read everything from an input stream into a String, reconstructing line endings. * * @param input * the stream to be read * @return a string that contains the content of input */ public static String readAll(InputStream input) { BufferedReader reader = new BufferedReader(new InputStreamReader(input)); StringBuffer buffer = new StringBuffer(); while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } if (line == null) { break; } else { buffer.append(line); buffer.append("\n"); } } return buffer.toString(); } }