Java Code Examples for org.apache.nifi.util.file.FileUtils#deleteFilesInDir()

The following examples show how to use org.apache.nifi.util.file.FileUtils#deleteFilesInDir() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ITestSFTPTransferWithSSHTestServer.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setupFiles() throws IOException {
    final File sftpRootDir = new File(SFTP_ROOT_DIR);
    FileUtils.deleteFilesInDir(sftpRootDir, null, LOGGER, true, true);

    // create and initialize dir1/child1
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_1 + "/" + DIR_1_CHILD_1, FILE_1, "dir1 child1 file1");
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_1 + "/" + DIR_1_CHILD_1, FILE_2, "dir1 child1 file2");
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_1 + "/" + DIR_1_CHILD_1, DOT_FILE, "dir1 child1 foo");

    // create and initialize dir1/child2
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_1 + "/" + DIR_1_CHILD_2, FILE_1, "dir1 child2 file1");
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_1 + "/" + DIR_1_CHILD_2, FILE_2, "dir1 child2 file2");
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_1 + "/" + DIR_1_CHILD_2, DOT_FILE, "dir1 child2 foo");

    // create and initialize dir2
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_2, FILE_1, "dir2 file1");
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_2, FILE_2, "dir2 file2");
    initializeFile(SFTP_ROOT_DIR + "/" + DIR_2, DOT_FILE, "dir2 foo");

    // Create a symbolic link so that dir3/dir1 links to dir1 so we can test following links
    final Path targetPath = Paths.get("../" + DIR_1);

    final String dir3Path = SFTP_ROOT_DIR + "/" + DIR_3;
    FileUtils.ensureDirectoryExistAndCanAccess(new File(dir3Path));
    final Path linkPath = Paths.get(dir3Path + "/" + DIR_1);

    Files.createSymbolicLink(linkPath, targetPath);

    // create dir4 for writing files
    final File dir4File = new File(SFTP_ROOT_DIR + "/" + DIR_4);
    FileUtils.ensureDirectoryExistAndCanAccess(dir4File);
}
 
Example 2
Source File: FileAuthorizerTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
private static boolean deleteFile(final File file) {
    if (file.isDirectory()) {
        FileUtils.deleteFilesInDir(file, null, null, true, true);
    }
    return FileUtils.deleteFile(file, null, 10);
}
 
Example 3
Source File: FileUserGroupProviderTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
private static boolean deleteFile(final File file) {
    if (file.isDirectory()) {
        FileUtils.deleteFilesInDir(file, null, null, true, true);
    }
    return FileUtils.deleteFile(file, null, 10);
}
 
Example 4
Source File: FileAccessPolicyProviderTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
private static boolean deleteFile(final File file) {
    if (file.isDirectory()) {
        FileUtils.deleteFilesInDir(file, null, null, true, true);
    }
    return FileUtils.deleteFile(file, null, 10);
}
 
Example 5
Source File: FileAuthorizerTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
private static boolean deleteFile(final File file) {
    if (file.isDirectory()) {
        FileUtils.deleteFilesInDir(file, null, null, true, true);
    }
    return FileUtils.deleteFile(file, null, 10);
}