Nonsense not much said, directly to everyone to paste code, the specific code as follows:
public string Getlocalhostname () {
string hostName;
try {
inetaddress addr = Inetaddress.getlocalhost ();
HostName = Addr.gethostname ();
} catch (Exception ex) {
hostName = "";
}
return hostName;
}
Public string[] Getalllocalhostip () {
string[] ret = null;
try {
String hostName = Getlocalhostname ();
if (hostname.length () > 0) {
inetaddress[] Addrs = Inetaddress.getallbyname (hostName);
if (Addrs.length > 0) {
ret = new String[addrs.length];
for (int i = 0; i < addrs.length i++) {
Ret[i] = Addrs[i].gethostaddress ();}} \
catch (Ex Ception ex) {
ret = null;
}
return ret;
}
The above code is a small series to introduce Java to get more than the local IP card code, there are questions welcome to my message, I will promptly communicate with you, learning and progress together, but also thank you for your support of cloud Habitat Community website!