I am trying to get my program display what the ipconfig
command displays in windows. I have managed to get the hostname and the IPv4 address, how can I get IPv6 address and subnet mask? I have tried various things to no avail so far. My code is:
try {
InetAddress addr = InetAddress.getLocalHost();
String ipAddr = addr.getHostAddress();
String hostname = addr.getHostName();
gsc.mainWindow.printf("Host name: ",hostname,"\n");
gsc.mainWindow.printf("IP Address: ",ipAddr,"\n");
} catch (Exception e) {
gsc.mainWindow.printf("Error: ",e,"\n");
}
Consider gsc.mainWindow
the out stream where I print any kind of object. Thanks in advance!
(PS.If anyone can add some tags I can't think of, I will be grateful!)