commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r633181 - in /commons/proper/net/branches/NET_2_0/src/main/java: examples/SubnetUtilsExample.java org/apache/commons/net/util/SubnetUtils.java
Date Mon, 03 Mar 2008 17:17:02 GMT
Author: rwinston
Date: Mon Mar  3 09:17:02 2008
New Revision: 633181

URL: http://svn.apache.org/viewvc?rev=633181&view=rev
Log:
Add getAllAddresses()

Modified:
    commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java
    commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java

Modified: commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java?rev=633181&r1=633180&r2=633181&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java (original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/examples/SubnetUtilsExample.java Mon
Mar  3 09:17:02 2008
@@ -16,6 +16,7 @@
  */
 package examples;
 
+import java.util.Arrays;
 import java.util.Scanner;
 
 import org.apache.commons.net.util.SubnetUtils;
@@ -52,7 +53,8 @@
 		System.out.printf("Last Usable Address:\t\t%s\t[%s]\n", info.getHighAddress(), 
 				Integer.toBinaryString(info.asInteger(info.getHighAddress())));
 		
-		System.out.printf("Total usable addresses: \t%d\n\n", info.getAddressCount());
+		System.out.printf("Total usable addresses: \t%d\n", info.getAddressCount());
+		System.out.printf("Address List: %s\n\n", Arrays.toString(info.getAllAddresses()));
 		
 		final String prompt ="Enter an IP address (e.g. 192.168.0.10):"; 
 		System.out.println(prompt);

Modified: commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java?rev=633181&r1=633180&r2=633181&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/main/java/org/apache/commons/net/util/SubnetUtils.java
Mon Mar  3 09:17:02 2008
@@ -87,6 +87,14 @@
 					format(toArray(netmask()))
 			);
 		}
+		
+		public String[] getAllAddresses() { 
+			String[] addresses = new String[getAddressCount()];
+			for (int add = low(), j=0; add <= high(); ++add, ++j) {
+				addresses[j] = format(toArray(add));
+			}
+			return addresses;
+		}
 	}
 
 	/**



Mime
View raw message