title: Reading file and placing into array
body: <p>I'm having troubles reading a file and then placing its contents into an array.  The console says my error is here: </p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  at readFile.readFile(readFile.java:23)
  at apples.main(apples.java:6)
  </code></pre>
  
  <p>However I do not now how to fix it.</p>
  
  <pre><code>import java.util.*;
  import java.lang.*;
  import java.io.*;
  
  
  public class readFile {
  private Scanner x;
  
  public void openfile(){
      try{
          x = new Scanner( new File("/Users/Zachary/Desktop/chinese.txt"));
  
      }
      catch (IOException e){
          System.out.println("you failed foo");
      }
  }
      public void readFile(){
          int y = 0;
          int[] nums = null;
          while(x.hasNext()){
              for(y=0; y&lt;10;y++) {
                  nums[y] = x.nextInt();
              }
              System.out.println(nums[y]);
          }
      }
      public void closeFile(){
          x.close();
      }
  }
  
  
  
  public class apples {
  public static void main (String[]args){
      readFile r = new readFile();
      r.openfile();
      r.readFile();
      r.closeFile();
  
  }
  }
  </code></pre>