Reading a file into an array Java -


Then I have a project in which I have to read book reference numbers and book titles from the .txt file in a reference, and then To enter a user reference number that will search for a book with that reference number, here I have what I have, keep in mind that I am not very experienced with Java

  public class book {Array List & Lt; String & gt; Books = New Arrestist & lt; String & gt; (); Bufredreader br = faucet; {Try {br = new buffed reader (new flamerdder ("BookList.txt")); String book; While ((book = br.readline ()) = null) books.add (book); }} Hold {IOException e} {end {try {br.close (}}} hold (IOException ex) {}} string [] book list = new string [books.size ()]; Books.toArray (Booklist); }}   

This file is to be read in an array list, and then converting the array list into an array is not 100% fixed. If this is correct, then if I have any problem, then I am glad Take your solution from

The problem is that when I try to set a method that allows the user to search

  private zero FindItActionPerformed (java.awt. ActionEvent evt) {string input; Input = input.getText (); I think the symbol book list can not be found an error, but I'm not sure that      

Thanks for the advice

Your init code is inside the Scotch bracket, the way you use a method The announcement has been lost.

You can not access the book list because it is not a class parameter but has been declared in the scope.

A method declaration ( try ) and declare it under its BufferedReader variable instead of declaring it in the bookList declaration Add.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -