aspose file tools*
The moose likes Java in General and the fly likes iterating a hashmap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "iterating a hashmap" Watch "iterating a hashmap" New topic
Author

iterating a hashmap

ronald zook
Greenhorn

Joined: Jul 31, 2007
Posts: 11
im writing a program that parses data from a log file. each line in the log is either a process wit a start time or an end time for one of the started processes. i already figured out how to print all the start times but i cant wrap my head around how to pull out the end time for each of the started processes. i want to put all the end times in a hashmap and iterate thru to find the end times for each process. the end times are usually within an hour of the start time. thanks in advance
Chris Corbyn
Ranch Hand

Joined: Jan 14, 2007
Posts: 114
I assume these processes have a unique identifier (i.e. the process ID) ? Without that you have nothing to link the times by.

You could do this one of two ways. Store an array (2 elements) in the HashMap where the process ID maps to the array:



To add a start time:



To add the end time:



You could use two parallel HashMaps too, but if you know it's alwayts going to be just two times for start and end that may be a bit overkill.

The subject of your thread suggested that you wanted to know how to iterate over the map, but from your message I'm guessing you already know that?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iterating a hashmap
 
Similar Threads
Threads behave in sequential Style
WebServer's process management
some help with java problem
App doesn't always close out
Monitoring logs statement in a live log file