我在尝试迭代属性文件中定义的值时遇到问题。 我正在尝试在循环中读取jar文件并将它们复制到目录中。 jar文件名在属性文件中定义。 这是我的示例文件:
<?xml version="1.0"?><project name="beehive" basedir="."> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <loadfile property="file.list" srcFile="test.txt"> <!--<filterchain> <striplinebreaks/> </filterchain>--> </loadfile> <target name="testtarget"> <for list="${file.list}" param="fileName"> <sequential> <echo>@{fileName}</echo> <copy file="C:/Development/Doc/Build/@{fileName}" todir="C:/Development/Doc/Build/testdir"> </copy> </sequential> </for> </target>这是test.txt中的条目。
wikihelp-1.0.0.jar
速度 - 1.0.0.jar
我期待for循环一次读取一个文件名,然后执行复制。 相反,它一起读取2个文件名并抛出以下异常:
警告:无法找到要复制的文件C:\ Development \ Doc \ Build \ wikihelp-1.0.0.jar velocity-1.0.0.jar。
任何指针将不胜感激。
谢谢I'm having issues in trying to iterate values defined in a property file. I'm trying to read jar files in a loop and copy them to a directory. The jar file names are defined in a property file. Here's my sample file :
<?xml version="1.0"?><project name="beehive" basedir="."> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <loadfile property="file.list" srcFile="test.txt"> <!--<filterchain> <striplinebreaks/> </filterchain>--> </loadfile> <target name="testtarget"> <for list="${file.list}" param="fileName"> <sequential> <echo>@{fileName}</echo> <copy file="C:/Development/Doc/Build/@{fileName}" todir="C:/Development/Doc/Build/testdir"> </copy> </sequential> </for> </target>Here's the entry in test.txt.
wikihelp-1.0.0.jar
velocity-1.0.0.jar
I'm expecting that the for loop will read file name one at a time then perform the copy. Instead,its reading the 2 file names together and throwing the following exception :
Warning: Could not find file C:\Development\Doc\Build\wikihelp-1.0.0.jar velocity-1.0.0.jar to copy.
Any pointers will be appreciated.
Thanks最满意答案
发现问题,添加delimiter =“$ {line.separator }解决了它
在for循环中,我需要为行分隔符添加分隔符
<for list="${file.list}" param="fileName" delimiter="${line.separator}">Found the issue, adding delimiter="${line.separator} resolved it
In the for loop, I needed to add the delimeter for line seperator
<for list="${file.list}" param="fileName" delimiter="${line.separator}">更多推荐
file,jar,文件,电脑培训,计算机培训,IT培训"/> <meta name="description"
发布评论