此任務用於設置任何字串或檔的長度屬性。它也可以用於顯示屬性值或作為條件。
它具有以下給出的各種屬性。
1. Apache Ant長度任務屬性
| 屬性 | 描述 | 必需 | 
|---|---|---|
property | 
用於設定長度 | 否 | 
mode | 
與檔長度模式一起使用 | 否 | 
file | 
要報告其長度的單個檔 | 否 | 
resource | 
報告長度的單一資源 | 否 | 
string | 
要報告的長度的字串 | 否 | 
trim | 
在處理字串時修剪 | 否 | 
length | 
比較長度 | 否 | 
when | 
比較類型:equal, eq和greater等等 | 
否 | 
下麵來看看一些設置字串和文件長度的例子。
2. Apache Ant長度任務示例
存儲字串長度:
<project name="java-ant project" default="run">
    <target name="run">
        <length string="Hello Javatpoint" property="length.foo"/>
        <echo message="length is: ${length.foo}"></echo>
    </target>
</project>
存儲檔長度:
<project name="java-ant project" default="run">
    <target name="run">
        <length file="abc" property="length.abc"/>
    </target>
</project>
將檔路徑及其長度存儲到length屬性中。
<project name="java-ant project" default="run">
    <target name="run">
        <length property="length" mode="each">
            <fileset dir="." includes="abc,xyz"/>
        </length>
    </target>
</project>
					
						上一篇:
								Ant Javac任務
												下一篇:
								Ant LoadFile任務
					
					