Manage a config file.
Hello all,
I'm writing a small application and I'll need to store configuration into a text file. I'd like to have a format like the .ini files under Windows:
[font]
name=Arial
size=10
color=123
[editor]
tabspace=8
Do you have any advice concerning that ? Would it be easy to it using XML ?
Thank you.
This is what u need buddy!!!
java.util.Properties prop = new java.util.Properties();
java.io.FileInputStream in = new java.io.FileInputStream("test.properties");
prop.load(in);
System.out.println(prop.getProperty("prop1"));
System.out.println(prop.getProperty("prop2"));
System.out.println(prop.getProperty("prop3"));
System.out.println(prop.getProperty("prop4"));
java.util.Properties prop1 = new java.util.Properties();
java.io.FileOutputStream out = new java.io.FileOutputStream("test11.properties");
prop1.setProperty("prop2", "opopop");
prop1.setProperty("prop7", "55555555555555555");
prop1.store(out,"tetetest");
and ur "test.properties" file may contain for ex: foll lines:
prop1=aaa
prop2=aaa
prop3=aaa
prop4=aaa
Pramod