You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2011/03/13 03:04:53 UTC

svn commit: r1081030 - /commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java

Author: sebb
Date: Sun Mar 13 02:04:52 2011
New Revision: 1081030

URL: http://svn.apache.org/viewvc?rev=1081030&view=rev
Log:
Add FEAT

Modified:
    commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java

Modified: commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java?rev=1081030&r1=1081029&r2=1081030&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java Sun Mar 13 02:04:52 2011
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.util.Arrays;
 
 import org.apache.commons.net.PrintCommandListener;
 import org.apache.commons.net.ftp.FTP;
@@ -33,6 +34,8 @@ import org.apache.commons.net.ftp.FTPRep
 import org.apache.commons.net.io.CopyStreamEvent;
 import org.apache.commons.net.io.CopyStreamListener;
 
+import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;
+
 /***
  * This is an example program demonstrating how to use the FTPClient class.
  * This program connects to an FTP server and retrieves the specified
@@ -47,10 +50,11 @@ public final class FTPClientExample
 {
 
     public static final String USAGE =
-        "Usage: ftp [-s] [-b] [-l] [-a] [-e] [-k secs [-w msec]] [-#] <hostname> <username> <password> <remote file> <local file>\n" +
+        "Usage: ftp [-s] [-b] [-l|-f] [-a] [-e] [-k secs [-w msec]] [-#] <hostname> <username> <password> <remote file> <local file>\n" +
         "\nDefault behavior is to download a file and use ASCII transfer mode.\n" +
         "\t-s store file on server (upload)\n" +
         "\t-l list files (local file is ignored)\n" +
+        "\t-f issue FEAT command (local file is ignored)\n" +
         "\t-# add hash display during transfers\n" +
         "\t-k secs use keep-alive timer (setControlKeepAliveTimeout)\n" +
         "\t-w msec wait time for keep-alive reply (setControlKeepAliveReplyTimeout)\n" +
@@ -64,6 +68,7 @@ public final class FTPClientExample
         boolean storeFile = false, binaryTransfer = false, error = false, listFiles = false;
         boolean localActive = false;
         boolean useEpsvWithIPv4 = false;
+        boolean feat = false;
         String server, username, password, remote, local;
         final FTPClient ftp = new FTPClient();
 
@@ -81,6 +86,9 @@ public final class FTPClientExample
             else if (args[base].equals("-e")) {
                 useEpsvWithIPv4 = true;
             }
+            else if (args[base].equals("-f")) {
+                feat = true;
+            }
             else if (args[base].equals("-l")) {
                 listFiles = true;
             }
@@ -196,6 +204,12 @@ __main:
                 }
                     
             }
+            else if (feat)
+            {
+                if (ftp.features()) {
+                    System.out.println(Arrays.toString(ftp.getReplyStrings()));
+                }
+            }
             else
             {
                 OutputStream output;