Having difficulty with ArrayList method ".contains", any feedback greatly appreciated!

Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Having difficulty with ArrayList method ".contains", any feedback greatly appreciated!

Hello, the objective of my program is to read a file called input_data.txt and to calculate an invoice in which my program will print the results in a formatted text file. I haven't advanced to this step yet because I'm having trouble checking my ArrayList for a certain string. The reason I am searching for "duration" is so that my program will know when the heading is complete.

Eventually, I must separate the fields and calculate payment prices based on the duration and time of the calls.
Any suggestions are much appreciated, even conceptual or logical suggestions because I feel I am not going in the right direction.

If you are committed to using an arraylist for this task, you may want to print out each object to see if it contains what you expect. If an arraylist is optional, GregBrannon's method would work very nicely.

The method that GregBrannon showed would work with any length as the array is only intended to hold one set of data (one line) at a time, not the entire file's text. So, you split the line into the 3 parts then do something with it, perhaps print it out or w/e you want really, and on the next iteration the values in the array would change to the next line; repeat process until the end of file.

I have attempted to implement the array solution and was able to gather the data in a (String) line of text. My problem is that I don't know how to use substring or split to obtain elements in that line of data. I need to retrieve the account number and total amounts (which will be calculated) in arraylists because these values (customers and total amount of total orders) is subject to change. Here is my updated code, no errors.

1. Format the input document so that the account numbers can be obtained and re-presented in the output file
2. Calculate the total amount with the start time and duration considered (I still must derive this algorithm)
3. Print these values to the invoice file