Peter Reilly wrote:
On 8/9/07, broken connection <[EMAIL PROTECTED]> wrote:
Hi Friends,
I take a directory path input from the end-user and store it in a
property,for example if its windows,it stores it as:
log4j.location=C:\tomcat\logs
This is not a valid property format: see
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)
so how do you store it?
Peter
Maybe not, but if you do <property name="log4j.location"
location="C:\tomcat\logs"/> on windows (of course), you will get exactly
what he describes. Also, if you use an input task, like it sounds like
he is doing, this is perfectly viable.
I use the ant-contrib propertyregex, such as:
<propertyregex property="log4.location.2" input="${log4j.location}"
regexp="\\" replace="\\\\\\\\"/>
Yes, all of those backslashes are necessary in the replace. Don't ask
me why. I assume they are getting de-referenced twice. It's not well
documented. I had to figure it out the hard way...by getting obtuse
errors and tweaking ramdomly until they went away.
See http://ant-contrib.sourceforge.net/tasks/tasks/index.html for more.
Also, it depends on what you are doing with the property whether any of
this matters or not. Most tasks happily accept the single backslashes.
--
Geoffrey Mitchell
Programmer/Analyst
Home Decorator's Collection
314-684-1062