获取本机IP地址
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
package socket;import java.net.InetAddress;import java.net.UnknownHostException;public class TestSocket { public static void main(String[] args) throws UnknownHostException { InetAddress host = InetAddress.getLocalHost(); String ip =host.getHostAddress(); System.out.println("本机ip地址:" + ip); }} |
浙公网安备 33010602011771号