ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: Split lines in input stream
Date Mon, 04 Aug 2008 21:00:58 GMT

--- srimh2o <sriram@mh2o.com> wrote:

> 
> Thanks, that worked. 
> 
> This is not just for testing purposes. My piece of
> build.xml looks like
> this:
> 
> 		<concat append="true"
> destfile="testing.jad">${attrib}
> 			<filterchain>
> 				<tokenfilter>
> 					<replacestring from="||"
> to="${line.separator}"/>
> 					<trim/>
> 					<linetokenizer/>
> 				</tokenfilter>
> 			</filterchain>
> 		</concat>
> 

The way you've got this arranged, the line
tokenization takes place before the string
replacement.  <linetokenizer> is the default tokenizer
used by token filters, so you could simplify your
<concat> invocation to:

  <concat destfile="testfile.jad"
append="true">${attrib}
    <filterchain>
      <replacestring from="||"
to="${line.separator}"/>
      <trim />
    </filterchain>
  </concat>

You might even want to add an <ignoreblank /> after
the trim as well, depending on your requirements.

-Matt

> ${attrib} is loaded with a string from a file that
> contains "||" as a marker
> for build.xml to know that this is a new line. But
> curiously, the output
> file testing.jad contains 2 spaces after the last
> line. I can't figure out
> where they are getting inserted. <trim> does not
> seem to get rid of them.
> Any suggestions?
> 
> Thanks for your help.
> 
> 
> Matt Benson wrote:
> > 
> > 
> > --- srimh2o <sriram@mh2o.com> wrote:
> > 
> >> 
> >> If this is complicated is there any way I can
> insert
> >> a linebreak between
> >> Hello and World?
> > 
> > If you're just doing this for testing purposes,
> Ant
> > loads all Java system properties, so you can
> insert
> > your platform separator by simply embedding
> > ${line.separator}.
> > 
> > -Matt
> > 
> >> 
> >> srimh2o wrote:
> >> > 
> >> > Ahh, this is verbatim, but you are correct. The
> >> \r\n does not substitute
> >> > for CRLF (0x0d, 0x0a). Then what I would like
> to
> >> do is somehow specify
> >> > Hello <CRLF> world and then get the output as:
> >> > Hello
> >> > World
> >> > 
> >> > Any suggestions on how to do this?
> >> > 
> >> > Thanks.
> >> > 
> >> > 
> >> > Scot P. Floess wrote:
> >> >> 
> >> >> Is this verbatim?  If so,, part of your
> problem
> >> is the literal characters 
> >> >> \r and \n are note the escaped counterparts...
> >> >> 
> >> >> Meaning if I had this:
> >> >> 
> >> >> Hello r n World
> >> >> 
> >> >> The r and the n are literals...and you'd see
> the
> >> same output as you are 
> >> >> seeing now...
> >> >> 
> >> >> 
> >> >> 
> >> >> On Mon, 4 Aug 2008, srimh2o wrote:
> >> >> 
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> I have a string input that contains carriage
> >> return "\r\n" and I'd like
> >> >>> to
> >> >>> use ant to split that input into two separate
> >> lines. This is what I do.
> >> >>>
> >> >>> <concat append="true"
> >> destfile="testing.jad">Hello \r\n World
> >> >>> 			<filterchain>
> >> >>> 				<tokenfilter />
> >> >>> 			</filterchain>
> >> >>> 		</concat>
> >> >>>
> >> >>> I'd like the output to look like this:
> >> >>> Hello
> >> >>> World
> >> >>>
> >> >>> Instead i get this:
> >> >>> Hello \r\n World
> >> >>>
> >> >>> Please help.
> >> >>>
> >> >>> Thanks
> >> >>> -- 
> >> >>> View this message in context:
> >> >>>
> >>
> >
>
http://www.nabble.com/Split-lines-in-input-stream-tp18814904p18814904.html
> >> >>> Sent from the Ant - Users mailing list
> archive
> >> at Nabble.com.
> >> >>>
> >> >>>
> >> >>>
> >>
> >
>
---------------------------------------------------------------------
> >> >>> To unsubscribe, e-mail:
> >> user-unsubscribe@ant.apache.org
> >> >>> For additional commands, e-mail:
> >> user-help@ant.apache.org
> >> >>>
> >> >>>
> >> >> 
> >> >> Scot P. Floess
> >> >> 27 Lake Royale
> >> >> Louisburg, NC  27549
> >> >> 
> >> >> 252-478-8087 (Home)
> >> >> 919-754-4592 (Work)
> >> >> 
> >> >> Chief Architect JPlate  
> >> http://sourceforge.net/projects/jplate
> >> >> Chief Architect JavaPIM 
> >> http://sourceforge.net/projects/javapim
> >> >> 
> >> >> Architect Keros         
> >> http://sourceforge.net/projects/keros
> >> >> 
> >> >>
> >>
> >
>
---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail:
> >> user-unsubscribe@ant.apache.org
> >> >> For additional commands, e-mail:
> >> user-help@ant.apache.org
> >> >> 
> >> >> 
> >> >> 
> >> > 
> >> > 
> >> 
> >> -- 
> >> View this message in context:
> >>
> >
>
http://www.nabble.com/Split-lines-in-input-stream-tp18814904p18816107.html
> >> Sent from the Ant - Users mailing list archive at
> >> Nabble.com.
> >> 
> >> 
> >>
> >
>
---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
> >> user-unsubscribe@ant.apache.org
> >> For additional commands, e-mail:
> >> user-help@ant.apache.org
> >> 
> >> 
> > 
> > 
> > 
> >       
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> user-help@ant.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/Split-lines-in-input-stream-tp18814904p18819201.html
> Sent from the Ant - Users mailing list archive at
> Nabble.com.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



      

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


Mime
View raw message