private String readToEnd ( InputStream inputStream ) { Scanner scanner = new Scanner ( inputStream ) . useDelimiter ( "\\A" ) ; return scanner . hasNext ( ) ? scanner . next ( ) : "" ; }
Reads the stream until it has no more bytes and returns a UTF - 8 encoded string representation .