title: Initialize array of objects from text files
body: <p>I have a program where I need to store users information, and add users. To make it persistent, the program reads all the users data and initializes an array of users upon launch, then saves the information before it closes. Here's my user class:</p>
  
  <pre><code>class User {
      String name;
      int val = -1;
      int oldVal = -1;
  
      public User(String n){
          try{
               BufferedReader dataReader = new BufferedReader(new FileReader("/Users/" + n));
               name = dataReader.readLine();
               val = Integer.parseInt(dataReader.readLine());
               oldVal = Integer.parseInt(dataReader.readLine());
          } catch (Exception e){}
      }
  </code></pre>
  
  <p>This class reads from files in /users, following the format name.txt</p>
  
  <pre><code> John
   90
   100
  </code></pre>
  
  <p>My core class looks like this:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileReader;
  
  class Core{
      public static void main (String[] args){
          int numUsers = -1;
          BufferedReader nameReader = null;
          User[] users = null;
  
          try {
              nameReader = new BufferedReader(new FileReader("Users/users.txt"));
              numUsers = Integer.parseInt(nameReader.readLine());
              users = new User[numUsers];
  
              for (int i = 0; i &lt; numUsers; i++){
                  users[i] = new User(nameReader.readLine());
              }
          } catch (Exception e) {
              System.out.println("Something went wrong. Aborting!");
              System.exit(1);
          }
          for (int i = 0; i &lt; numUsers; i++){
              System.out.println("User " + users[i].getName() + "\n Val:" + users[i].getVal() + "\n oldVal: " + users[i].getOldVal());
          }
      }
  }
  </code></pre>
  
  <p>But running core returns:</p>
  
  <pre><code>User null
  val: -1
  oldVal: -1
  </code></pre>
  
  <p>for every user. 
  What is the problem? Is the system I've made viable, or do I need to change the foundation of my program entirely? </p>
  
  <p>(EDIT to change tags)</p>