Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-16-2009, 04:35 PM
Member
 
Join Date: Mar 2009
Posts: 18
Rep Power: 0
turanan is on a distinguished road
Default apache commons vfs delete directory with dependancies
I'm new to vfs and I want to know how I can remove a directory, which is not empty.

The following code seems to remove single files and empty directories quite easily:

Code:
    public void testRemoveRemoteFile() throws FileSystemException {
        FileSystemOptions fsOptions = new FileSystemOptions();
        SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(
                fsOptions, "no");
        DefaultFileSystemManager fsManager = (DefaultFileSystemManager) VFS.getManager();
        if (fsManager.resolveFile("sftp://user:pass@host/remotepath/", fsOptions).exists()) {
            fsManager.resolveFile("sftp://user:pass@host/remotepath/", fsOptions).delete();
            System.out.println("File removed successfully");
        }
    }
But I want my code to be able to remove directories, which have files or sub-directories in them. The spec says, that we should use fileObject.delete(FileSelector); instead of fileObject.delete();
but so far I haven't been able to use this method, as I don't know what this FileSelector type parameter should contain. If anyone has encountered this problem, please post an example, which removes non-empty files.

Thanks,
Andrew

Last edited by turanan; 06-16-2009 at 04:37 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Apache Commons (StringUtils etc...) work with Eclipse? chrvi New To Java 2 09-28-2009 07:26 PM
[SOLVED] Apache Commons Properties file exceptions edwardmluk Java Servlet 1 03-06-2009 05:24 PM
[SOLVED] To Delete All subdir in a directory tOpach New To Java 3 11-18-2008 01:29 PM
FTP private directory problems with org.apache.commons.net.ftp.FTP magaupe Advanced Java 0 09-13-2008 08:58 PM
org.apache.commons.mail.EmailException: Cannot find valid hostname Ed Advanced Java 2 07-02-2007 09:03 PM


All times are GMT +2. The time now is 10:19 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org