Question: How do I read a text file into an ArrayList? This is my code below. It's in a class, the photo is edited, so I

How do I read a text file into an ArrayList? This is my code below. It's in a class, the photo is edited, so I do have the class headers in the actual file. I tried to call it in my main using an object of the class. Obj.ReadLibrary(). It gives me a NullPointerException.

 How do I read a text file into an ArrayList? This

String filename "BookList.txt": String lin Array List String> aList new ArrayList String> public void ReadLibrary try BufferedReader input new BufferedReader (new FileReader (filename)) if (!input ready throw new IOException while (line input. readLine null) List add (line) input close catch (IOException e) System, out.println (e) int size aList size for (int i 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!