# FileTree

interface FileTree : FileCollection

A `FileTree` represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a `FileTree` to represent files to copy or the contents of an archive.

You can obtain a `FileTree` instance using fileTree, zipTree or tarTree.

The order of the files in a `FileTree` is not stable, even on a single computer.

#### Inheritors

ConfigurableFileTree
SourceDirectorySet

## Functions

addToAntBuilder
Link copied to clipboard
abstract fun addToAntBuilder(builder: Any, nodeName: String): Any
abstract fun addToAntBuilder(builder: Any, nodeName: String, type: FileCollection.AntType)
Adds this collection to an Ant task as a nested node.
abstract fun addToAntBuilder(node: Any, childNodeName: String): Any
contains
Link copied to clipboard
abstract fun contains(file: File): Boolean
Determines whether this collection contains the given file.
filter
Link copied to clipboard
abstract fun filter(filterClosure: Closure): FileCollection
abstract fun filter(filterSpec: Spec<in File>): FileCollection
Restricts the contents of this collection to those files which match the given criteria.
forEach
Link copied to clipboard
open fun forEach(action: Consumer<in T>)
getAsFileTree
Link copied to clipboard
abstract fun getAsFileTree(): FileTree
Returns this.
getAsPath
Link copied to clipboard
abstract fun getAsPath(): String
Returns the contents of this collection as a platform-specific path.
getBuildDependencies
Link copied to clipboard
abstract fun getBuildDependencies(): TaskDependency
Returns a dependency which contains the tasks which build this artifact.
getElements
Link copied to clipboard
abstract fun getElements(): Provider<Set<FileSystemLocation>>
Returns the contents of this file collection as a Provider of FileSystemLocation instances.
getFiles
Link copied to clipboard
abstract fun getFiles(): Set<File>
Returns the contents of this tree as a flattened Set.
getSingleFile
Link copied to clipboard
abstract fun getSingleFile(): File
Returns the content of this collection, asserting it contains exactly one file.
isEmpty
Link copied to clipboard
abstract fun isEmpty(): Boolean
Returns true if this collection is empty.
iterator
Link copied to clipboard
abstract fun iterator(): Iterator<T>
matching
Link copied to clipboard
abstract fun matching(@DelegatesTo(value = PatternFilterable::class) filterConfigClosure: Closure): FileTree
abstract fun matching(filterConfigAction: Action<in PatternFilterable>): FileTree
abstract fun matching(patterns: PatternFilterable): FileTree
Restricts the contents of this tree to those files matching the given filter.
minus
Link copied to clipboard
abstract fun minus(collection: FileCollection): FileCollection
Returns a `FileCollection` which contains the difference between this collection and the given collection.
plus
Link copied to clipboard
abstract fun plus(collection: FileCollection): FileCollection
Returns a `FileCollection` which contains the union of this collection and the given collection.
abstract fun plus(fileTree: FileTree): FileTree
Returns a `FileTree` which contains the union of this tree and the given tree.
spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<T>
visit
Link copied to clipboard
abstract fun visit(@DelegatesTo(value = FileVisitDetails::class) visitor: Closure): FileTree
abstract fun visit(visitor: Action<in FileVisitDetails>): FileTree
abstract fun visit(visitor: FileVisitor): FileTree
Visits the files and directories in this file tree.