public static String readStream(InputStream is) throws IOException {
if(is == null) return null;
final Scanner scanner = new Scanner(new BufferedInputStream(is), "UTF-8");
scanner.useDelimiter("\\A");
final String content = scanner.hasNext() ? scanner.next() : "";
final IOException readException = scanner.ioException();
scanner.close();
if(readException != null) {
throw new IOException(readException);
}
return content;