Reading from & Writing to Property.lax File

Hi Everyone

I have a small application that uses a Property File that was created by InstallAnywhere Free Now, Version 4. I interrogate this file to see if it contains all the necessary information I need to run my application. If it does not contain the information, I then add on to this Property.lax file. But it then overrides all the comments that was made by InstallAnywhere. Could somebody please explain to me how I can overcome this problem. Below is an example of how I read and write to & from the Property.lax file.

java.util.Properties prop =new java.util.Properties();

File f =new File(sPropertyLax,"PropertyLax.lax");

if (f.exists())

{

FileInputStream fi =new FileInputStream(f);

prop.load(fi);

String sVm =null;

String sClass =null;

sVm = prop.getProperty("lax.nl.current.vm","" + sVm);

sClass = prop.getProperty("lax.class.path","" + sClassPath);

sVm = sVm.substring(0, sVm.indexOf("bin\\jre.exe"));

if ((!sClass.endsWith(sVm)) && (!sClass.startsWith(sVm)))

{

FileOutputStream fo =new FileOutputStream(f);

sClass +=";" + sVm;

prop.put("lax.class.path=",sClassPath);

prop.save(fo,"");

}

fi.close();

}

I'd appresiate it if somebode could please help me with this propblem. Thanx

Ciao

[1974 byte] By [Chardenay] at [2007-9-26 7:03:26]
# 1

When adding a property, do not use prop.put()... instead when you know you have to add a property, simply append the new line(s) at the end of the original file.

prop.save() will simply write what is stored in the hashtable, which does not include comments, just the name/value pairs.

ashutosh at 2007-7-1 16:41:05 > top of Java-index,Core,Core APIs...
# 2
To append create outputstream this way:FileOutputStream fo = new FileOutputStream("path/profilename", true);String that needs to be appended:String toAppend = "lax.class.path=" + sClassPath;
ashutosh at 2007-7-1 16:41:05 > top of Java-index,Core,Core APIs...