File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android 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: 41150
    
  45
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?


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing the Properties File
 
Similar Threads
Reading Properties file with spaces in key
Display HashMap contents
about resource bundle
using two properties files in struts
reading properties file