Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3420764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:02:42+00:00 2026-05-18T06:02:42+00:00

I’m having an issue with writing out a property which holds the value of

  • 0

I’m having an issue with writing out a property which holds the value of a directory path into a property file.

My script originally reads in this particular property, call it ‘appserver.home’, from a props file using the <property file="source.props"/>. I’ve echoed the value coming in and it reads correctly as C:\\somedir\\jboss_4_2_3.

What my script needs to do next is provide this value to another properties file (used by another ant script – though that’s not important). To create this other file I’m using a kind off template file with place holders surrounded by $….$ to insert the correct values in the correct place, using the following :-

 <copy file="template_file.props" tofile="target.props">
    <filterset begintoken="$" endtoken="$">
        <filter token="appServerDir" value="${appserver.home}"/>
        <filter token="dbusername" value="${database.name}"/>
        ....
    </filterset>
 </copy>                

The problem is that the value now in the target.props is C:\somedir\jboss_4_2_3 ie it’s lost the escape characters. When the next ant script uses this file it interprets the property value as C:somedirjboss_4_2_3.

So the question how do I tell ant that the value I’m writing is a file path ?
Note I have tried the following, which actually works :-

<propertyfile file="target.props">
    <entry key="appServerDir" value="${appserver.home}"/>
</propertyfile>

.. ie it outputs the name as c\:\\somedir\\jboss4_2_3, but I’d rather not use this technique and rather use the template file technique, as it contains some properties which are always static, as well as comments etc.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:02:42+00:00Added an answer on May 18, 2026 at 6:02 am

    There’s some perhaps confusing differences between tasks in respect of the treatment of escapes going on here.

    When you say that ‘appserver.home’ echoes correctly, I guess you are using the ‘echoproperties’ task which shows you the value stored without interpolating escapes. And that shows the same number of escapes as in your ‘source.props’ file.

    The problem is that, in general, when Ant interpolates this value in to a string it will consume the escapes, hence they disappear. An exception to this is in the ‘propertyfile’ task, where you would normally want the escapes retained in the output property file – as you have observed – in order that the file can be read properly later.

    So, what to do?

    Perhaps the simplest thing is to make sure that the properties read from ‘source.props’ retain their escapes for use in later filters. So instead of using

    <property file="source.props"/>
    

    to load, use

    <loadproperties srcfile="source.props">
        <filterchain>
            <replacestring from="\" to="\\" />
        </filterchain>
    </loadproperties>
    

    That should ensure that your escape sequences propagate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.