Use a debugger or add some debug statements to your code such as read the file token into a String, and then print it out with a println statement immediately after obtaining it and just before you put it into the arraylist.

Print out the entire ArrayList contents with a println statement immediately after the while loop.

Clean up your code. Poorly formatted code is hard for us to understand and hard for you or us to debug.

Sorry about that. Sometimes, I format it afterwards, but that is just my test file to make sure that it works. Why would i print out the entire ArrayList contents with a println statement immediately after the while loop when it will only use 1 line of the file. The file has multiple lines and I need it to search entire file...

November 5th, 2012, 12:45 PM

anonb

Re: Need Help Fast - Please Help in Java ArrayList

Also, when you mentioned:
Use a debugger or add some debug statements to your code such as read the file token into a String, and then print it out with a println statement immediately after obtaining it and just before you put it into the arraylist.

Are you saying to use a tokenizer or something? If so, I don't see what the difference is because it is reading the entire file by using the loop. Please explain...

November 5th, 2012, 02:29 PM

curmudgeon

Re: Need Help Fast - Please Help in Java ArrayList

I am recommending that you do these things so you can figure out why your program is not working. You need to do some debugging.

November 5th, 2012, 03:22 PM

anonb

Re: Need Help Fast - Please Help in Java ArrayList

I have been debugging. I have been using system.out.println to see what the file is reading and that is how i kow it is reading the entire file. However, it looks as if it is just reading line by line, instead of all the elements within the line. I've also come to find out that ArrayList only searches for objects and that is why it keeps saying it is false. How do I convert my String search, which is the users input to an object?

November 5th, 2012, 04:26 PM

curmudgeon

Re: Need Help Fast - Please Help in Java ArrayList

Strings *are* objects, and so your search may be correct. I suggest that you:
1) post the contents of the text file.
2) put in the println I was mentioning and show us the results from that.
3) show us what the user enters.