● ローカルアドレスの取得2
getLocalHost()
getLocalHost()
---------------------------------------------------------------
import java.net.*;
public class IPAddress2 {
public static void main(String args[]) {
//
InetAddress host = null;
try {
host = InetAddress.getLocalHost();
}
catch(UnknownHostException e) {
System.err.println(e);
return;
}
System.out.println(host);
}
}
---------------------------------------------------------------