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.

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
Get step-by-step solutions from verified subject matter experts
