dcsimg
How can i read a ini file using java
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   krishnakumar_venkat
Posted On:   Tuesday, March 2, 2004 07:06 AM

I want to read a ini file(Actually that is a file with .ini extension.) from servlet.How that can be done using java.I tried to use fileReader class,Bufferedreader class and used input.readline() to read that file line by line, but nothing works out.

Please help me by giving examples to read a ini file.


Thaks

Re: How can i read a ini file using java

Posted By:   Ruben_Misrahi  
Posted On:   Thursday, May 6, 2004 01:18 PM

Look at the Properties class.
You can use:
Porperties properties = new Propeties();
FileInputStream stream = new FileInputStream("MyFile.ini");
properties.load(stream);
for (Enumeration e=properties.propertyNames(); e.hasMoreElements();){
String s = (String)e.nextElement();
String value = properties.getProperty(s);
}
... You get the idea

Re: How can i read a ini file using java

Posted By:   Steven_Martin  
Posted On:   Tuesday, March 2, 2004 07:24 AM

What are you trying to do with the file? It's text so you should be able to read with BufferedReader then you'll have to do your own parsing.
About | Sitemap | Contact