The question probably needs a few more details. What part of the solution is causing you trouble?
- The scheduling?
- The reading from the network?
- The persistence in a memory data structure?
- The writing to a file?
You should also describe the problem domain a little bit more in detail since it might significantly affect any solution that might be offered. For example:
- What is the nature of the data going over the network?
- Does it have to be per minute? What if the network isn't done sending and the minute is up and you start reading?
- What exactly does the ArrayList contain?
- Can you describe the file output? (text file? serialized object? etc...)
Just an initial hunch on my part --some thoughts I would have when designing a solution for the problem you described would involve some kind of Producer-Consumer approach.
- A Runnable/Thread object whose sole responsibility is to continuously read from the network, assemble the data and place it in a synchronized queue.
- A Runnable/Thread object in a wait() state observing the synchronized queue. When signaled by the queue, it will start reading the contents of the queue for persistence to a file(s).
- When there are items in the queue (or when a certain threshold is reached) it will notify() the waiting queue reader to start consuming the objects from the queue for persistence.
I maybe completely off base, but the fact that you're reading from the network implies some sort of unpredictability and unreliability. So instead of relying on timers, I would rely on the Producer of data (object reading from the network) signal the Consumer (the object that will use the data read from the network) to do something with the data.