commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Commons Wiki] Update of "SimpleSftpFileDownload" by KenTanaka
Date Tue, 29 Apr 2008 21:51:51 GMT
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/SimpleSftpFileDownload

The comment on the change is:
Noted an alternative method for closing the file system down.

------------------------------------------------------------------------------
   * "\\." is an escaped "\." which means a literal period instead of a wild card interpretation
of "."
  
  It is important to call 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. Otherwise the program will appear to hang after downloading files.
+ 
  
  = Source Code =
  The code provided below is for a Maven 2 project.
@@ -269, +270 @@

      } // process(Object obj)
  
  
+     /**
+      * Release system resources, close connection to the filesystem. 
+      */
      public void release() {
          ((DefaultFileSystemManager) this.fsManager).close();
      } // release()
  } // class App
+ }}}
+ 
+ Note that there is an alternative method to casting fsManager to !DefaultFileSystemManager
and then calling close(). The release method could instead use {{{this.fsManager.closeFileSystem(this.fs);}}},
you would have to declare '''fs''' as a !FileSystem object in the class and set it from one
of the !FileObjects in the process routine:
+ {{{
+ FileObject src = fsManager.resolveFile(from);
+ FileSystem fs = null;
+ FileSystemManager fsm = null;
+ 
+ <-- do your things -->
+ 
+ src.close(); // Seems to still work even if this line is omitted
+ fs = src.getFileSystem(); // This works even after the src is closed.
+ fsm = fs.getFileSystemManager();
+ fsm.closeFileSystem(fs);
  }}}
  
  = Compiling =

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message