获取本机IP地址_.net
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);
    }
}