Results 1 to 1 of 1
- 06-16-2009, 03:35 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 19
- Rep Power
- 0
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:
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();Java 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 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,
AndrewLast edited by turanan; 06-16-2009 at 03:37 PM.
Similar Threads
-
How to make Apache Commons (StringUtils etc...) work with Eclipse?
By chrvi in forum New To JavaReplies: 3Last Post: 01-29-2012, 10:44 AM -
org.apache.commons.mail.EmailException: Cannot find valid hostname
By Ed in forum Advanced JavaReplies: 3Last Post: 07-25-2011, 03:19 PM -
[SOLVED] Apache Commons Properties file exceptions
By edwardmluk in forum Java ServletReplies: 1Last Post: 03-06-2009, 04:24 PM -
[SOLVED] To Delete All subdir in a directory
By tOpach in forum New To JavaReplies: 3Last Post: 11-18-2008, 12:29 PM -
FTP private directory problems with org.apache.commons.net.ftp.FTP
By magaupe in forum Advanced JavaReplies: 0Last Post: 09-13-2008, 07:58 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks