Here you can find the source of readAll(InputStream stream)
Parameter | Description |
---|---|
stream | The stream to read. |
null
if the stream was empty.
public static String readAll(InputStream stream)
//package com.java2s; //License from project: LGPL import java.io.*; import java.util.Scanner; public class Main { /**// w ww. j a v a2 s . c om * Reads the entire content of a stream to a string. * * @param stream The stream to read. * @return The string read from the stream or <code>null</code> if the stream was empty. */ public static String readAll(InputStream stream) { Scanner scanner = new Scanner(stream).useDelimiter("\\A"); return scanner.hasNext() ? scanner.next() : null; } }