public class

FileTree

extends Object
java.lang.Object
   ↳ com.facebook.common.file.FileTree

Class Overview

Utility class to visit a file tree. There's similar functionality in Java 7's Files.walkFileTree method. Its methods could be merge into FileUtil (although it seems to have a lot of crazy redundant methods, maybe for testing, but crazy anyway).

Summary

Public Constructors
FileTree()
Public Methods
static boolean deleteContents(File directory)
Deletes all files and subdirectories in directory (doesn't delete the directory passed as parameter).
static boolean deleteRecursively(File file)
Deletes the file and if it's a directory deletes also any content in it
static void walkFileTree(File directory, FileTreeVisitor visitor)
Iterates over the file tree of a directory.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FileTree ()

Public Methods

public static boolean deleteContents (File directory)

Deletes all files and subdirectories in directory (doesn't delete the directory passed as parameter).

public static boolean deleteRecursively (File file)

Deletes the file and if it's a directory deletes also any content in it

Parameters
file a file or directory
Returns
  • true if the file/directory could be deleted

public static void walkFileTree (File directory, FileTreeVisitor visitor)

Iterates over the file tree of a directory. It receives a visitor and will call its methods for each file in the directory. preVisitDirectory (directory) visitFile (file) - recursively the same for every subdirectory postVisitDirectory (directory)

Parameters
directory the directory to iterate
visitor the visitor that will be invoked for each directory/file in the tree