Link to home
Start Free TrialLog in
Avatar of yngvi
yngvi

asked on

Using ini files in Java

I want my program to read a ini file when it starts up. It looks like this :

[Settings #1]
connection=192.13.5.4
Port=4658

[Settings #2]
conneciton=198.15.4.86
port=5844

I want variables to get information from the ini file.

well you get the picture. Is there any easy way to do this ?

Avatar of heyhey_
heyhey_

if you don't need sections
>> [Settings #1]


you can use java.util.Properties
else use manual parsing,

heyhey,
ur Email ID has changed?  Got a bouncer now.
wanted to send a nice link to you,send me a mail at my profile account.
1Define a property file which contains
connection=198.15.4.86
port=5844

and save it to any filename (e.g. app.properties)

and to retrieve the value. Do this

Properties props = new Properties()
FileInputStream fis = new FileInputStream("app.properties");
        props.load(fis);
String connection = props.getProperty("connection");
String port = props.getProperty("port");

heyhey_@iname.com is working - I receive a lot of e-mails there.

heyhey@nettaxi.com is another option.
I wrote a class to read ini file, if you want I can send to you.
ASKER CERTIFIED SOLUTION
Avatar of jadrek85
jadrek85

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial