This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing the Properties File  RSS feed

 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!