This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Accessing the Properties File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing the Properties File " Watch "Accessing the Properties File " New topic

Accessing the Properties File

Senthil Kumar
Ranch Hand

Joined: Oct 14, 2007
Posts: 33
Hi all,
Iam trying to acces the Properties in my code.
But the Keys are accessed in the same order as it is in the Properties file.
Iam using the following code.

properties.load(new FileInputStream("C:\\"));
enumProperties = properties.propertyNames();
key = (String)enumProperties.nextElement();

Is there a way to access the Keys in the same way as it is defined in the Properties File?

Thanks in advance
Senthil Kumar.S
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
Is there a way to access the Keys in the same way as it is defined in the Properties File?

Not through the Properties class. You'd have to read and parse the file in your own code. But properties are not meant to have an ordering; they constitute a map (or hash table). Why is that important - maybe there are other ways of achieving what you need done?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Accessing the Properties File
It's not a secret anymore!