Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetUtil hostName 疑似有问题 #136

Open
zhhaojie opened this issue Oct 31, 2018 · 1 comment
Open

NetUtil hostName 疑似有问题 #136

zhhaojie opened this issue Oct 31, 2018 · 1 comment

Comments

@zhhaojie
Copy link

zhhaojie commented Oct 31, 2018

public static void main(String[] args) {
		String a = NetUtil.getLocalAddress().getHostName();
		String b = NetUtil.getLocalAddress().getHostAddress();

		String x = NetUtil.getHostName();
		String y = NetUtil.getLocalHost();

		System.out.println("a=" + a);
		System.out.println("b=" + b);
		System.out.println("x=" + x);
		System.out.println("y=" + y);
	}

上面这个例子. 我在 mac os 上面测试
结果如下:

a=xxx.local
b=172.30.60.29
x=null  //这个没问题么?
y=172.30.60.29

@AJ-Liang
Copy link
Collaborator

AJ-Liang commented Jan 8, 2019

环境是什么呢?windows 可以看看环境变量COMPUTERNAME有没设置,echo %COMPUTERNAME%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants