title: How to read multiple integer values from one line in Java using BufferedReader object?
body: <p>I am using BufferedReader class to read inputs in my Java program.
  I want to read inputs from a user who can enter multiple integer data in single line with space.
  I want to read all these data in an integer array.</p>
  
  <p>Input format-
  the user first enters how many numbers he/she want to enter</p>
  
  <p>And then multiple integer values in the next single line-</p>
  
  <p>INPUT:</p>
  
  <p>5</p>
  
  <p>2 456 43 21 12</p>
  
  <p>Now, I read input using an object (br) of BufferedReader</p>
  
  <pre><code>int numberOfInputs = Integer.parseInt(br.readLine());
  </code></pre>
  
  <p>Next, I want to read next line inputs in an array</p>
  
  <pre><code>int a[] = new int[n];
  </code></pre>
  
  <p>But we cannot read using this technique</p>
  
  <pre><code>for(int i=0;i&lt;n;i++)
  {
     a[i]=Integer.parseInt(br.readLine()); //won't work
  }
  </code></pre>
  
  <p>So, is there any solution to my problem or we can't just read multiple integers from one line using BufferedReader objects</p>
  
  <p>Because using Scanner object we can read this type of input</p>
  
  <pre><code>for(int i=0;i&lt;n;i++)
  {
     a[i]=in.nextInt(); //will work..... 'in' is object of Scanner class
  }
  </code></pre>