title: Is it optimal to use BufferedReader instead of Scanner Class for multiple integers on a single line in Java?
body: <p>As buffered reader is much faster than scanner class in case of inputting values from the user, however as observed in most of the Algorithm Competitions or in case of interviews there are often multiple integers on a single input line. Hence, it becomes easier to use Scanner Class -</p>
  
  <pre><code>    Scanner in=new Scanner(System.in);
      int a=in.nextInt();
      int b=in.nextInt();
  </code></pre>
  
  <p>In case of Buffered Reader, you will have to first input a line (as there is no option of readInt) and then parse the line according to number of integers on it -</p>
  
  <pre><code>    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int a,b;
      String line = br.readLine(); 
      String[] strs = line.trim().split("\\s+");
      a=Integer.parseInt(strs[0]);
      b=Integer.parseInt(strs[1]);
  </code></pre>
  
  <p>Although the input may be faster in latter case, won't the parsing take up much time to divide the obtained string into indiviual integers?
  Hence, in such case which one of the above is more optimal or faster?</p>
  
  <p>Thank you.</p>