Java编程实现获取本机IP和计算机名的功能

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Test {

	public static void main(String[] args) {
		try {
			InetAddress inetAddress = InetAddress.getLocalHost();
			System.out.println("本机IP:"	+ inetAddress.getHostAddress().toString());
			System.out.println("本机名称:" + inetAddress.getHostName().toString());
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}
}

Java编程实现获取本机IP和计算机名的功能,布布扣,bubuko.com

Java编程实现获取本机IP和计算机名的功能

上一篇:leecode 树是否是平衡树 java


下一篇:JavaScript Patterns 5.6 Static Members