title: Java Reading a txt that has different numbers in its column file and store data in an arraylist
body: <p>Hello Guys I have a txt file below, I need to store the second column data but it gives me an error since some lines have 1 some have 2 and some have 3 input in each line. How can I solve that problem?</p>
  <pre><code>
  5
  3 4
  3 4
  3 3
  3 4
  3 3
  3 4
  3 3
  3 2
  3 4
  3 3
  3 2
  3 1
  3 4
  3 3
  3 2
  3 1
  3 0
  1
  2
  5 3 4
  3 4
  3 4
  3 3
  3 4
  3 3
  3 4
  3 3
  3 2
  3 4
  3 3
  3 2
  3 1
  3 4
  3 3
  3 2
  3 1
  3 0
  1
  2
  5 4 6
  4 4
  4 4
  4 4
  4 4
  4 4
  4 4
  4 3
  4 3
  4 3
  4 3
  4 4
  4 4
  1
  2
  5 4 6
  0
  </code></pre>
  <p>Here is what I did, I tried to differentiate as the size and in the other way but still cant get the answer...</p>
  <pre><code>String line = &quot;&quot;;
  
  ArrayList&lt;String&gt; numbers= new ArrayList&lt;String&gt;();
  
  try {
  
      String sCurrentLine;
      br = new BufferedReader(new FileReader(&quot;input1.txt&quot;));
      int n = 0;
  
      while ((sCurrentLine = br.readLine()) != null) {
          String[] arr = sCurrentLine.split(&quot; &quot;);
          int size = arr.length;
  
          List&lt;String&gt; list = ConvertToList.convertArrayToList(arr);
          List&lt;Integer&gt; listOfInteger = convert.convertStringListToIntList(list, Integer::parseInt);
          if (list.size() == 2) {
              line.split(&quot;\\s+&quot;);
              numbers.add(line.split(&quot;\\s+&quot;)[0]);
              System.out.println(numbers);
          }
      }
  } catch(Exception e) {
      e.printStackTrace();
  }
  </code></pre>