[Assorted-commits] SF.net SVN: assorted:[1473] sandbox/trunk/src/java/Ipconfig.java
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-09-21 05:39:34
|
Revision: 1473 http://assorted.svn.sourceforge.net/assorted/?rev=1473&view=rev Author: yangzhang Date: 2009-09-21 05:39:24 +0000 (Mon, 21 Sep 2009) Log Message: ----------- added demo of ipconfig-like util Added Paths: ----------- sandbox/trunk/src/java/Ipconfig.java Added: sandbox/trunk/src/java/Ipconfig.java =================================================================== --- sandbox/trunk/src/java/Ipconfig.java (rev 0) +++ sandbox/trunk/src/java/Ipconfig.java 2009-09-21 05:39:24 UTC (rev 1473) @@ -0,0 +1,37 @@ +import java.net.*; +import java.util.*; +/** + * <p>Lists the IP interfaces defined on the system using the Java NetworkInterface.</p> + * <p>ale...@pa...</p> + * <p>Copyright (c) 2003 Alexis Grandemange</p> + * <pre>This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; version 2.1 of the + * License. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * A copy of the GNU Lesser General Public License lesser.txt should be + * included in the distribution.</pre> + * @author Alexis Grandemange + * @version 0, 0, 1 + */ +public class Ipconfig { + Ipconfig() throws Exception { + Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); + while(en.hasMoreElements()) { + NetworkInterface ni = en.nextElement(); + Enumeration<InetAddress> en2 = ni.getInetAddresses(); + while(en2.hasMoreElements()) { + InetAddress ia = en2.nextElement(); + System.out.println("Interface name:" + ni.getName() + + " display name:" + ni.getDisplayName() + " " + + ia.getHostAddress()); + } + } + } + public static void main(String[] args) throws Exception { + new Ipconfig(); + } +} Property changes on: sandbox/trunk/src/java/Ipconfig.java ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |