ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: putting value in txtfile
Date Wed, 26 Jan 2005 16:01:40 GMT
--- Erik Hatcher <erik@ehatchersolutions.com> wrote:

> Um.... nevermind..... I missed the part that there
> is "just a blank 
> line".  A custom FilterReader would work - have it
> only affect the 4th 
> line.
> 
> 	Erik

All you have to match is the line break count, so
assuming you know what those are (use fixcrlf worst
case)  tokenfilter + filetokenizer + replaceregex
works.  My self-contained example (with Jakarta ORO as
my regexp engine):

<project>
  <property name="br" value="${line.separator}" />
  <property name="insert" value="hello world" />

  <echo file="foo.txt" append="false">01
bla${br}</echo>
  <echo file="foo.txt" append="true">02
bla${br}</echo>
  <echo file="foo.txt" append="true">03
bla${br}</echo>
  <echo file="foo.txt" append="true">04 ${br}</echo>
  <echo file="foo.txt" append="true">05 ${br}</echo>
  <echo file="foo.txt" append="true">06 ${br}</echo>
  <echo file="foo.txt" append="true">07
bla${br}</echo>
  <echo file="foo.txt" append="true">08
bla${br}</echo>
  <echo file="foo.txt" append="true">09
bla${br}</echo>

  <copy file="foo.txt" tofile="bar.txt">
    <filterchain>
      <tokenfilter>
        <filetokenizer />
        <replaceregex
pattern="^(.*${br}.*${br}.*${br}.*)(${br}.*)"
                      replace="\1${insert}\2" />
      </tokenfilter>
    </filterchain>
  </copy>
</project>

-Matt


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message