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 Thu, 05 Nov 2009 17:48:37 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Commons Wiki" for change notification.

The "SimpleSftpFileDownload" page has been changed by KenTanaka.
The comment on this change is: Completed updated to example code, fixing an error if you need
to release and then re-initialize to run the process method more than once..
http://wiki.apache.org/jakarta-commons/SimpleSftpFileDownload?action=diff&rev1=16&rev2=17

--------------------------------------------------

      private FileSystemOptions opts = null;
      private FileObject sftpFile;
  
+     private FileObject src = null; // used for cleanup in release()
  
      public static void main(String[] args) {
          System.out.println("SFTP download");
@@ -272, +273 @@

                          f.getName(), ex);
              }
          } // for (FileObject f : children)
+ 
+         // Set src for cleanup in release()
+         src = children[0];
      } // process(Object obj)
  
  
@@ -279, +283 @@

       * Release system resources, close connection to the filesystem. 
       */
      public void release() {
-         ((DefaultFileSystemManager) this.fsManager).close();
+         FileSystem fs = null;
+ 
+         fs = this.src.getFileSystem(); // This works even after the src is closed.
+         this.fsManager.closeFileSystem(fs);
      } // release()
  } // class App
  }}}

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


Mime
View raw message