Example usage for org.apache.commons.vfs FileObject delete

List of usage examples for org.apache.commons.vfs FileObject delete

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject delete.

Prototype

public int delete(FileSelector selector) throws FileSystemException;

Source Link

Document

Deletes all descendents of this file that match a selector.

Usage

From source file:pt.webdetails.cpf.repository.VfsRepositoryTest.java

/**
 * Please do note this will remove the folder and all subfolders and files Used for testing purposes only
 *
 * @param file//from   w  w  w  .  ja v  a2s .c o m
 * @return
 */
public int removeUnsafe(String file) {
    try {
        if (file.equals(".")) {
            return repo.delete(Selectors.EXCLUDE_SELF);
        }
        FileObject f = resolveFile(repo, file);
        if (f.exists()) {
            return f.delete(Selectors.SELECT_ALL);
        }
        return -1;
    } catch (Exception e) {
        throw new RuntimeException("Cannot delete file: " + file, e);
    }
}