commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1074007 - /commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
Date Thu, 24 Feb 2011 01:22:14 GMT
Author: sebb
Date: Thu Feb 24 01:22:14 2011
New Revision: 1074007

URL: http://svn.apache.org/viewvc?rev=1074007&view=rev
Log:
Allow port to be specified as part of server name

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=1074007&r1=1074006&r2=1074007&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 Thu Feb 24 01:22:14
2011
@@ -73,6 +73,12 @@ public final class FTPClientExample
         }
 
         server = args[base++];
+        int port = 21;
+        String parts[] = server.split(":");
+        if (parts.length == 2){
+            server=parts[0];
+            port=Integer.parseInt(parts[1]);
+        }
         username = args[base++];
         password = args[base++];
         remote = args[base++];
@@ -85,7 +91,7 @@ public final class FTPClientExample
         try
         {
             int reply;
-            ftp.connect(server);
+            ftp.connect(server, port);
             System.out.println("Connected to " + server + ".");
 
             // After connection attempt, you should check the reply code to verify



Mime
View raw message