public static void readLines(InputStream stream,Consumer<String> lineProcessor) throws IOException {
  try (BufferedReader reader=new BufferedReader(new InputStreamReader(stream))){
    String line=null;
    while ((line=reader.readLine()) != null) {
      lineProcessor.accept(line);
    }
  }
 }

public static void readLines ( InputStream stream , Consumer < String > lineProcessor ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( stream ) ) ) { String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { lineProcessor . accept ( line ) ; } } }
read the lines from the supplied stream . this function completely reads the stream and therefore closes the stream .
