Package test; import Java. io. bufferedreader; import Java. io. ioexception; import Java. io. inputstreamreader;/*** @ author javaalpha * @ date 2011-12-14 * @ Version V 1.0 * Java Code Call the DOS ipconfig/all command to obtain the NIC details */public class ipconfig {/*** @ Param ARGs */public static void main (string [] ARGs) {// obtain the machine name string hostname = getlocalmachineinfo ("Host Name ............: "); system. out. println ("machine name:" + hostname); // obtain the NIC model string DESC = getlocalmachineinfo ("Description ...........: "); system. out. println ("Nic model:" + DESC); // obtain the MAC address string MAC = getlocalmachineinfo ("physi Cal address .........: "); system. out. println ("MAC address:" + Mac); // obtain the IP address string IP = getlocalmachineinfo ("ip address ............: "); system. out. println ("IP Address:" + IP); // obtain the subnet mask string subnetmask = getlocalmachineinfo ("subnet mask ...........: "); system. out. println ("subnet mask:" + subnetmask); // obtain the default gateway string DefaultGateway = getlocalmachineinfo ("Default Gateway .........: "); sys TEM. out. println ("machine name:" + DefaultGateway); // obtain the DNS Server String dnsservers = getlocalmachineinfo ("DNS servers ...........: "); system. out. println ("machine name:" + dnsservers);} static string getlocalmachineinfo (string Str) {string line = ""; int N; try {process PS = runtime.getruntime(cmd.exe C ("CMD/C ipconfig/all"); bufferedreader BR = new bufferedreader (New inputstreamreader (PS. getinputstream (); While (null! = (Line = Br. Readline () {If (line. indexof (STR )! =-1) {n = line. indexof (":"); line = line. substring (n + 2); break;} ps. waitfor ();} catch (ioexception e) {e. printstacktrace ();} catch (exception e) {e. printstacktrace () ;}return line ;}}