Import java.net. inet4address; import java.net. inet6address; import java.net. inetaddress; import java.net. networkinterface; import Java. util. enumeration;/*** socket learning ** @ author administrator **/public class inteaddressexample {public static void main (string [] ARGs) {// network interface and related address information of the active host try {enumeration <networkinterface> interfacelist = networkinterface. getnetworkinterfaces (); If (interfacelist = NULL) {System. out. println ("no interface found");} else {While (interfacelist. hasmoreelements () {networkinterface iface = interfacelist. nextelement (); // getname () returns the local interface. The local name of the interface is usually composed of letters and numbers. out. println ("Interface Name:" + iface. getname () + ":"); enumeration <inetaddress> addrlist = iface. getinetaddresses (); If (! Addrlist. hasmoreelements () {system. out. println ("\ t (corresponding address not found under this interface)");} while (addrlist. hasmoreelements () {inetaddress address = addrlist. nextelement (); system. out. println ("\ taddress" + (address instanceof inet4address? "(V4)": (address instanceof inet6address? "(V6 )":"(?) "); System. out. println (":" + address. gethostaddress () ;}}} catch (exception e) {e. printstacktrace () ;}// obtain the host name and address for each parameter input by the command line for (string HOST: ARGs) {try {system. out. println (host + ":"); inetaddress [] Addresslist = inetaddress. getallbyname (host); For (inetaddress Address: Addresslist) {system. out. println ("\ t" + address. gethostaddress () + "/" + address. gethostaddress () ;}} catch (exception e) {e. printstacktrace ();}}}}