• Post Reply Bookmark Topic Watch Topic
  • New Topic

Any idea about load property file in group?  RSS feed

 
Alex Sun
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need load a property file in group, the content of property file is like this.

[General]
ServerName=javaranch.com
Port=80000

[Users]
user1=xxx
user2=yyy
user3=zzz

[Communicate1]
Index=true
Encrypt=false
Key=xyz

[Communicate2]
Index=false
Encrypt=true
Key=ddd


Any idea how can I load each property to the section which it belong to?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you've got there is not technically a "properties file"; it's a "Windows INI file." Properties files don't have those section headers.

The JDK doesn't offer native support for INI files, but there are plenty of third-party libraries that handle them; here's one:

http://ini4j.sourceforge.net/
 
Alex Sun
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Ernest.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!