title: I am looking for the code to successfully store the information read from my input file into an ArrayList in Java
body: <p>This is what I have tried so far... I have a method inside of this package in a separate class called loadData(String) that loads the data inside an input file. However this use of the loadData method gives an error saying this type is undefined for LibraryApplication.</p>
  
  <pre><code>import java.io.File;
  import java.util.ArrayList;
  import java.util.Scanner;
  import java.io.FileNotFoundException;
  
  public class LibraryApplication {
  
      public static void main(String[] args) throws FileNotFoundException{
              try {
                  Scanner x = new Scanner(new File("BookCatalog.txt"));
                  ArrayList&lt;Book&gt; booklist = new ArrayList&lt;Book&gt;();
                  loadData()
              } 
              catch (FileNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }    
          }    
      }
  
      public void loadData(String filename) {
  
          this.filename = filename;
  
          Scanner reader = null;
          try {
              reader = new Scanner(new File(filename));
              Book book = null;
  
              while (reader.hasNextLine()) {
                  book = new Book(reader.nextLine(), reader.nextLine(), reader.nextLine(), reader.nextLine(),
                          Integer.parseInt(reader.nextLine()));
                  reader.next();
                  booklist.add(book);
              }
              booklist.sort(null);
              reader.close();
          } catch (IOException e) {
              System.out.print("Error: Unable to load file. ");
          }
      }
  }
  </code></pre>