File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Property File Iteration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Property File Iteration" Watch "Property File Iteration" New topic

Property File Iteration

Alan Sperling

Joined: May 21, 2004
Posts: 2
I'm trying to get a list of the key/value pairs in a property file without using the java.util.Properities.list() method. I'd like to iterate over the key/value pairs using an iterator object, but haven't figured out the right combination of objects to use. Can someone point me in the right direction. This is what I have thus far:

Thanks for any help,
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
I would consider using the split method of the String class, then interating over the resulting array, using the even index elements for the key and the odd index elements for the value.

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Alan Sperling

Joined: May 21, 2004
Posts: 2
Please excuse the caos, my first time posting on JavaRanch and thought the code blocks would handle my code better than it looked in text mode.

Here's a cleaned up version - hopefully.

I agree. Here's the link:
subject: Property File Iteration
Similar Threads
Properties/Settings - a design question
Writing Encrypted Strings
Implement a data structure that support a sorted Map.
Matching Up Items From One Array With A Text File