Example usage for org.apache.hadoop.fs AbstractFileSystem delete

List of usage examples for org.apache.hadoop.fs AbstractFileSystem delete

Introduction

In this page you can find the example usage for org.apache.hadoop.fs AbstractFileSystem delete.

Prototype

public abstract boolean delete(final Path f, final boolean recursive)
        throws AccessControlException, FileNotFoundException, UnresolvedLinkException, IOException;

Source Link

Document

The specification of this method matches that of FileContext#delete(Path,boolean) except that Path f must be for this file system.

Usage

From source file:org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsUtils.java

License:Apache License

/**
 * Deletes all files from the given file system.
 *
 * @param fs The file system to clean up.
 * @throws IOException On error.//from   w  w  w  .  ja va2 s .  c om
 */
public static void clear(AbstractFileSystem fs) throws IOException {
    // Delete root contents:
    FileStatus[] statuses = fs.listStatus(new Path("/"));

    if (statuses != null) {
        for (FileStatus stat : statuses)
            fs.delete(stat.getPath(), true);
    }
}