ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: How to do CONCAT task in ANT 1.4.1
Date Thu, 27 Jun 2002 17:37:22 GMT
--- Steve Loughran <steve_l@iseran.com> wrote:
> ----- "Arthur Lim" <ArthurLim@ap.savi.com> wrote: 
> > I see that there is a CONCAT task in Ant1.5. However, I need to do a
> > concatentation of 3 files under Ant 1.4.1. Is a there a way?
> 
> no, not without <exec> ing an OS command

Au contraire -- you can always <script> it :)

  <target name="concat">
    <property name="catfiles" value="foo.txt,bar.txt"/>
    <property name="outfile" value="all.txt"/>
    <script language="javascript"> <![CDATA[
      importClass(java.io.BufferedReader);
      importClass(java.io.FileReader);
      importClass(java.io.FileWriter);
      importClass(java.util.StringTokenizer);
      srcfile = projname.getProperty("catfiles");
      outfile = projname.getProperty("outfile");
      linesep = projname.getProperty("line.separator");
      out = null;
      fr = null;
      line = null;
      if( outfile != null && outfile != "" ) {
        out = new FileWriter(outfile);
      }
      st = new StringTokenizer(catfiles, ",");
      while (st.hasMoreTokens()) {
        file = st.nextToken();
        fr = new FileReader(file);
        br = new BufferedReader(fr);
        line = new String();
        while ((line = br.readLine()) != null) {
          if( out != null ) {
            out.write(line);
            out.write(linesep);
          } else {
            projname.log("    [concat] " + line);
          }
        }
        br.close();
      }
      if( out != null ) { out.close(); }
      if( fr != null ) { fr.close(); }
    ]]></script>
  </target>

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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


Mime
View raw message