Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
How to convert back slashes to forward slashes

How to convert back slashes to forward slashes

2007-08-09       - By glenn opdycke-hansen
Reply:     1     2     3     4     5     6  

I believe you need to use the <pathconvert> task, see
http://ant.apache.org/manual/CoreTasks/pathconvert.html
Below is from an example:

   <path id="wl.path">
     <pathelement location="${wl.home}/lib/weblogicaux.jar"/>
     <pathelement location="${wl.home}/classes"/>
     <pathelement location="${wl.home}/mssqlserver4/classes"/>
     <pathelement location="c:\winnt\System32"/>
   </path>

   <pathconvert targetos="unix" property="wl.path.unix" refid="wl.path">
     <map from="${wl.home}" to="${wl.home.unix}"/>
     <map from="c:" to=""/>
   </pathconvert>

will generate the path shown below and store it in the property named
wl.path.unix.

/weblogic/lib/weblogicaux.jar:/weblogic/classes:/weblogic/mssqlserver4/classes:
/WINNT/SYSTEM32


--glenn

On 8/9/07, broken connection <brokenconnection@(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
>
> And that messes up everything.Because \t is interpreted as tab. So, how
> can
> i change the backward slashes(windows convention) to forward slashes(unix
> convention) in the property before my build file is executed????
>
> Or, how to escape them eg "\" to "\\"
>
> I would appreciate your help.
> Thanks
> Mick
>

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.