title: Reading a file into an array Java
body: <p>So I have a project in which I have to read book reference numbers and book titles from a .txt file into an array, and then a user is to enter a reference number that will do a search for the book with that reference number, so here is what i have, Keep in mind I'm not very experienced with java</p>
  
  <pre><code>public class Book {
  
  
  ArrayList&lt;String&gt;  books = new ArrayList&lt;String&gt;();
  BufferedReader br = null;
  
   {
      try {
          br = new BufferedReader(new FileReader("BookList.txt"));
          String  book;
              while ((book = br.readLine()) != null) {
                  books.add(book);
              }
       } catch (IOException e){
       } finally {
           try {
               br.close();
           } catch (IOException ex) {
           }
       }
  
  
      String [] bookList = new String[books.size()];
      books.toArray(bookList);
  
  
      }
  }
  </code></pre>
  
  <p>That is to read the file into an array list, and then convert the array list into an array
  Im not 100% sure if that's right so if theres a problem, I would gladly take your solution.</p>
  
  <p>The problem i'm having is when i try to set up a method that allows a user to search</p>
  
  <pre><code>private void FindItActionPerformed(java.awt.event.ActionEvent evt) {                                       
     String input;
     input = Input.getText();
  
     for(int i=0; i&lt;bookList.length; i++){
  
     }
  
  
     }    
  </code></pre>
  
  <p>I get an error that says cannot find symbol bookList, but im not sure what why</p>
  
  <p>Thanks for any help or advice you may be able to offer</p>