Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read .ini file from java code

 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

I want to read a .ini file using java.
how I can achieve this ?

thanks
Swapnil
 
Maneesh Godbole
Saloon Keeper
Posts: 11196
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh is right. An .ini file is nothing more than a text file with special formatting:

- starting with ; for comments
- [] around section headings
- key=value for the rest
 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ini4j
 
swapnel surade
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileReader is normal file operation.
In that I have to read line by line and parse the string.

is there any other api which will provide me key value option like properties file.
 
Adam Michalik
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I mentioned above, ini4j will allow you to access each section and key of an ini file in a convenient way. But reading such a file with Properties#load should also work - the ini header sections will be inserted to the Properties as keys with empty values, so you can simply forget about them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic