如何使用ant脚本从文件中逐行读取数据? [英] How to read data line by line from a file using ant script?

查看:38
本文介绍了如何使用ant脚本从文件中逐行读取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 perl 中,我们使用 通过 ilne 从文件中读取数据行.如何使用 ant 脚本执行相同操作.

In perl we use <FileDescriptor> to read data line by ilne from a file. How to do the same using ant script.

推荐答案

您可以使用 loadfile 任务与 for 来自 ant-contrib 的任务(你必须下载并安装ant-contrib).

You can do that using the loadfile task in combination with the for task from ant-contrib (you will have to download and install ant-contrib).

<project name="test" default="compile">

  <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
      <pathelement location="path/to/ant-contrib.jar"/>
    </classpath>
  </taskdef>

  <loadfile property="file" srcfile="somefile.txt"/>

  <target name="compile">
    <for param="line" list="${file}" delimiter="${line.separator}">
      <sequential>
        <echo>@{line}</echo>
      </sequential>
    </for>
  </target>

</project>

这篇关于如何使用ant脚本从文件中逐行读取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆