title: How to read a text file in java and assign lines to variables
body: <p>Here is the code I wrote :</p>
  
  <pre><code>    try {   
          String[] Flight_Inputs = null;
          Scanner in = new Scanner(f); // f = input file
          int counter =0;
          while(in.hasNextLine()) {
              Flight_Inputs[counter++] = in.next();
            //Flight_Inputs = in.nextLine().split("\n"); // Also tried this
          }
          in.close(); 
           for(int i = 0,j=0; i &lt; Flight_Inputs.length; i++){
               Boeing.setDestination_from(Flight_Inputs[j++]);
               Boeing.setDestination_to(Flight_Inputs[j++]);
               Boeing.setName(Flight_Inputs[j++]);
           }
  </code></pre>
  
  <p>I am getting Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException error I tried also other variations and got an error that I was trying to access index 1 of Flight_Inputs but compiler says it doesnt exist.</p>
  
  <p>What I want to do do is simply get some lines from the text file and assign them to variables of Boieng object... Any help would be appreciated!</p>