aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing the Properties File " Watch "Accessing the Properties File " New topic
Author

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:\\SampleProperties2.properties"));
enumProperties = properties.propertyNames();
while(enumProperties.hasMoreElements()){
key = (String)enumProperties.nextElement();
System.out.println(key+"---->"+properties.getProperty(key));
}


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
Marshal

Joined: Mar 22, 2005
Posts: 42915
    
  68
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing the Properties File