Dear Wiki user, You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.
The following page has been changed by KenTanaka: http://wiki.apache.org/jakarta-commons/VfsFaq The comment on the change is: Added a Q and A for "How do I keep an SFTP connection from hanging?" ------------------------------------------------------------------------------ VfsCookbook - a cookbook has been started - == How to enter ftp passive mode == + == How can I enter ftp passive mode? == {{{ FileSystemOptions opts = new FileSystemOptions(); @@ -15, +15 @@ FileObject fo = VFS.getManager().resolveFile("ftp://host/path_to/file.txt", opts); }}} - == How to use the org.apache.commons.vfs.FileSelector or org.apache.commons.vfs.FileFilter == + == How do I use the org.apache.commons.vfs.FileSelector or org.apache.commons.vfs.FileFilter? == The FileFilter can be used to mimic the java.io.FileFilter interface. @@ -58, +58 @@ VFS.getManager().resolveFile("/base/folder").findFiles(ff); }}} + == How do I keep an SFTP connection from hanging? == + If your program is transferring files, but not exiting afterward, this is actually an issue with properly closing down the connection when you are done. If you acquired a !FileSystemManager with + + {{{ + private FileSystemManager fsManager = VFS.getManager(); + }}} + + the getManager() method probably returned a [http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/impl/StandardFileSystemManager.html StandardFileSystemManager] which extends the !DefaultFileSystemManager class and implements the !FileSystemManager interface. + + What you are probably after is the [http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/impl/DefaultFileSystemManager.html#close() close()] method of the !DefaultFileSystemManager to clean up any temporary files and close all providers. Cast the !FileSystemManager to a !DefaultFileSystemManager access the close() method like this: + + {{{ + ((DefaultFileSystemManager) fsManager).close(); + }}} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
