read/write to .ini file
confusion on .ini file
I have a .ini file as such:
StartDate=5/27/2006
LastRunDate=6/18/2007
[OutputDirectory]
LogPath=C:\Me
When I run this code:
import java.util.*;
import java.io.*;
public class readIni {
public static void main(String[] args) {
readIni ini = new readIni();
ini.doit();
}
public void doit() {
try {
Properties properties = new Properties();
properties.load(new FileInputStream("user.ini"));
String string = properties.getProperty("LogPath");
properties.setProperty("LogPath", "test");
properties.store(new FileOutputStream("test.ini"), null);
} catch (IOException e) {
}
}
}
I get the output as such:
#Wed Jul 18 11:01:53 PDT 2007
[OutputDirectory]=
LogPath=test
LastRunDate=6/18/2007
StartDate=5/27/2006
I want it to appear as such:
StartDate=5/27/2006
LastRunDate=6/18/2007
[OutputDirectory]=
LogPath=test
Why do I get the output all mixed up and the add-in date information of
#Wed Jul 18 11:01:53 PDT 2007?
Please help.
Thanks.
[1195 byte] By [
mana07a] at [2007-11-27 10:58:55]

many thanks for the needed direction.
I ended up using BufferedReader and PrintWriter.
Through much trial and error finally able to get it to work where I am able to
-grab the contents of .ini file
-manipulate it
-send it back to same .ini file
thanks again :-)
man07
> what version of jdk do I need for this.
> I have version jdk1.5.0_12 and am using eclipse.
> i am unable to reference this:
>
> import org.ini4j.Ini;
Java 1.5 is probably fine. You just need to add that JAR file you downloaded to your CLASSPATH. In Eclipse, you can do that like this:
- right-click your Eclipse project;
- in the left menu: select "Properties";
- in the next left menu: select "Java Build Path";
- select the "Libraries" tab;
- click the button "Add External JARs...";
- locate the JAR file org.ini4j.Ini is supposed to be in.
> I don't have a local copy of this.
> where can I download this org.ini4j.Ini .jar file?
> I checked Sun and was not able to find it.
>
> many thanks.
See reply #5. In the top of the page there is a download link.