title: Getting the first line of a file with java
body: <p>I am trying to get the first line of a file with java and I am not sure why it is not working or why I am getting the error i am getting. This is the first time I have tried this in java.</p>
  
  <p>Error</p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 16
      at getSum.main(getSum.java:33)
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>import java.io.BufferedInputStream;
  import java.io.DataInputStream;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.File;
  import java.io.FileNotFoundException;
  public class getSum {
  
      public static void main(String[] args) {
              File file = new File("path/InputArray.txt");
              FileInputStream fis = null;
              BufferedInputStream bis = null;
              DataInputStream dis = null;
              String line = null;
              try{
                  fis = new FileInputStream(file);
                  bis = new BufferedInputStream(fis);
                  dis = new DataInputStream(bis);
  
                  while(dis.available() != 0){
                      line = dis.readLine();
                  }
              }catch (FileNotFoundException e){
                  e.printStackTrace();
              }catch (IOException e){
                  e.printStackTrace();
              }
              String[] splitLine = line.split("\\s+");
              int[] numbers = new int[splitLine.length];
  
              for(int i = 0; i&lt; line.length(); i++){
                  try{
                      numbers[i] = Integer.parseInt(splitLine[i]);
                  }catch(NumberFormatException nfe){};
              }
  
  
             int amount = 0;
             System.out.print(numbers.length);
             /*amount = sumArray(0,numbers.length,numbers.length,numbers);
             System.out.print("Total: " + amount);*/
      }
  </code></pre>