Here you can find the source of loadInputAsString(InputStream is)
public static String loadInputAsString(InputStream is)
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { /**//ww w . j a v a2 s. co m * Something really straight forward to read the content of the file. * It is just jetty.xml: no need to be really fast and optimized here. */ public static String loadInputAsString(InputStream is) { StringBuilder sb = new StringBuilder(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); //$NON-NLS-1$ String newline = System.getProperty("line.separator"); //$NON-NLS-1$ String line = null; while ((line = reader.readLine()) != null) { sb.append(line + newline); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } return sb.toString(); } }