File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes how to read .ini file from java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to read .ini file from java code" Watch "how to read .ini file from java code" New topic
Author

how to read .ini file from java code

swapnel surade
Ranch Hand

Joined: Mar 05, 2009
Posts: 129
hi guys,

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

thanks
Swapnil
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10519
    
    9

FileReader ?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19759
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Adam Michalik
Ranch Hand

Joined: Feb 18, 2008
Posts: 128
ini4j
swapnel surade
Ranch Hand

Joined: Mar 05, 2009
Posts: 129
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

Joined: Feb 18, 2008
Posts: 128
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read .ini file from java code