## Length

Since Apache Ant 1.6.3

### Description

Display or set a property containing length information for a string, a file, or one or more nested resource collections. Can also be used as a `condition`.

### Parameters

Attribute | Description | Required
--- | --- | ---
Task | Condition
property | The property to set. | No; by default, output value to the log | Ignored
mode | File length mode; when all the resulting value is the sum of all included resources' lengths; when each the task outputs the absolute path and length of each included resource, one per line. | No; default is all | Ignored
file | Single file whose length to report. | One of these, or one or more nested filesets
resource | Single resource whose length to report (using extended properties handling). Since Ant 1.8.1
string | The string whose length to report.
trim | Whether to trim when operating on a string. | No; default is false, ignored unless string is set
length | Comparison length. | Ignored | Yes
when | Comparison type: equal, eq, greater, gt, less, lt, ge (greater or equal), ne (not equal), le (less or equal). | Ignored | No; default is equal

### Parameters specified as nested elements

#### resource collections

You can include resources via nested resource collections.

### Examples

Store the length of the string foo in the property named `length.foo`.

    <length string="foo" property="length.foo"/>

Store the length of file `bar` in the property named `length.bar`.

    <length file="bar" property="length.bar"/>

Store the file paths of `foo` and `bar` and their length into the property `length`.

    <length property="length" mode="each">
        <fileset dir="." includes="foo,bar"/>
    </length>

Add the length of `foo` and `bar` and store the result in property `length`.

    <length property="length" mode="all">
        <fileset dir="." includes="foo,bar"/>
    </length>