Share on Google+Share on Google+

File Separator

Advertisement
This example allows you to build platform-specific paths and directory hierarchies.

File Separator

     

This example allows you to build platform-specific paths and directory hierarchies. When you build a path with any of ant's task, Ant is quite happy to convert the separators in to ones appropriate for the operating system on which it is running. Ant will also do the conversion if you pass the string that you have built to its tasks. Therefore, you could rewrite the previous listing. 

 

 

 

 Source code of build.xml:

<project name="FileSeperator" default="echo" basedir=".">

  <target name="echo">

  <echo message="The File name is: ${basedir}${file.separator}build.xml"/>

  <echo message="The directory Path is: ${basedir}${file.separator}build.xml${path.separator}
   ${basedir}${file.separator}build.properties"/>

  </target>

</project>


If the display shows a mixture of file separators, don't disturb ant that is still treating these as strings. The following output will be displayed if you execute ant command on the command prompt.

Download Source Code

     

Advertisements

Advertisement

Posted on: September 6, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Comments:0