Hi I need some help with arraylists, I am trying to load a text file into an array list with the following method:
I use netbeans, and have to make things work with a GUI. I can display the contents of this file in a JTextArea by pressing a Display button. What I would like to know is how to proceed from here. I want to be able to search the arraylist for a particular word when typed in the GUI and then display it. How is this possible. I have spent hours to figure this out so far and couldnt come up with a solution.Code:public static ArrayList LoadFile(JTextArea src){
String line = "";
ArrayList data = new ArrayList();
try{
FileReader fr = new FileReader("Products.txt");
BufferedReader br = new BufferedReader(fr);
while ((line = br.readLine()) != null){
src.append(line);
src.append(System.getProperty("line.separator"));
}
}catch(FileNotFoundException fN) {
fN.printStackTrace();
}
catch(IOException e){
System.out.println(e);
}
return data;
Also the above arraylist is defined in a class, while the search and display is done in the MainFrame class.
Hope some one can show me to the right direction.
thanks

