You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by mathapfahl <Ni...@dekra.com> on 2007/05/23 11:15:44 UTC
Problem with File Input Output with Jelly,Ant,Maven1
Hi,
I have a problem. I want to read the content of a file. If a special string
is in the file, then I want to go further. If not I want to write the string
in the file.
Does anyone have an idea how I should realize this ?
I begin with
<goal name="filetest">
<util:loadText file="test.txt" var="content"></util:loadText>
<ant:if test="${content.contains('special string;')}">
<echo>gut</echo>
</ant:if>
</goal>
please help me
--
View this message in context: http://www.nabble.com/Problem-with-File-Input-Output-with-Jelly%2CAnt%2CMaven1-tf3802802s177.html#a10760207
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Problem with File Input Output with Jelly,Ant,Maven1
Posted by Lukas Theussl <lt...@apache.org>.
I don't think you can check for string content like that; the following
works for me (you'll need commons.lang on your classpath):
<goal name="filetest">
<util:loadText file="test.txt" var="content"></util:loadText>
<j:invokeStatic className="org.apache.commons.lang.StringUtils"
method="contains" var="contains">
<j:arg value="${content}" type="java.lang.String"/>
<j:arg value="special string;" type="java.lang.String"/>
</j:invokeStatic>
<j:choose>
<j:when test="${contains}">
<echo>gut</echo>
</j:when>
<j:otherwise>
<echo>schlecht</echo>
</j:otherwise>
</j:choose>
</goal>
HTH,
-Lukas
mathapfahl wrote:
> Hi,
>
> I have a problem. I want to read the content of a file. If a special string
> is in the file, then I want to go further. If not I want to write the string
> in the file.
>
> Does anyone have an idea how I should realize this ?
>
> I begin with
> <goal name="filetest">
> <util:loadText file="test.txt" var="content"></util:loadText>
> <ant:if test="${content.contains('special string;')}">
> <echo>gut</echo>
> </ant:if>
> </goal>
>
> please help me
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org