示例#1
0
 public static void main(String[] args) throws Exception {
   FtpClient ftpClient = new FtpClient("ftp://my.server.de");
   List<String> fileNames = ftpClient.listFiles("*.rec");
   for (String fileName : fileNames) {
     File localFile = ftpClient.downloadFile(fileName, "Bx3A2v34fhq4367");
     System.out.println("FILE: " + localFile);
   }
 }
示例#2
0
 /** Cleans up the connection to the server. */
 private void closeConnection(final FtpClient client) {
   try {
     // Clean up
     if (client.isConnected()) {
       client.disconnect();
     }
   } catch (final IOException e) {
     // getLogger().warn("vfs.provider.ftp/close-connection.error", e);
     VfsLog.warn(getLogger(), log, "vfs.provider.ftp/close-connection.error", e);
   }
 }
示例#3
0
  /** Creates an FTP client to use. */
  public FtpClient getClient() throws FileSystemException {
    synchronized (this) {
      if (idleClient == null || !idleClient.isConnected()) {
        idleClient = null;

        FtpClient ftpClient =
            new FTPClientWrapper((GenericFileName) getRoot().getName(), getFileSystemOptions());
        return ftpClient;
        /*
        final GenericFileName rootName = (GenericFileName) getRoot().getName();

        return FtpClientFactory.createConnection(rootName.getHostName(),
            rootName.getPort(),
            rootName.getUserName(),
            rootName.getPassword(),
            rootName.getPath(),
            getFileSystemOptions());
        */
      } else {
        final FtpClient client = idleClient;
        idleClient = null;
        return client;
      }
    }
  }