String hostIp =
inet address net address = getine address();
hostIp = getHostIp(net address);
Return to hostIp
}
public static inet address getinet address(){
Try {
Returns inetaddress. getlocalhost ();
} catch (UnknownHostException e) {
System.out.println ("Unknown host!" );
}
Returns null
}
Public static string gethostip (inetaddress netaddress) (
if (null == netAddress) {
Returns null
}
string IP = net address . gethostaddress(); //get the ip address
Return to IP;
}
Public static string gethostname (inetaddress netaddress) (
if (null == netAddress) {
Returns null
}
string name = net address . get hostname(); //Get the host address
Returns the name;
}