public static String readAsString ( InputStream is ) throws IOException { try { // Scanner iterates over tokens in the stream, and in this case // we separate tokens using "beginning of the input boundary" (\A) // thus giving us only one token for the entire contents of the // stream return new Scanner ( is , "UTF-8" ) . useDelimiter ( "\\A" ) . next ( ) ; } catch ( java . util . NoSuchElementException e ) { return "" ; } }
Read data from input stream