使用Guava获取私有域名时出错 [英] errors when using Guava to get the private domain name
本文介绍了使用Guava获取私有域名时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 guava-18.0
和 java1.6
给出以下代码:
String host = null;
host = new URI(this.domain).getHost();
Pattern p = Pattern.compile("[a-zA-Z]");
Matcher m = p.matcher(host);
if(m.find()){
InternetDomainName domainName = InternetDomainName.from(host);
this.domain = domainName.topPrivateDomain().name();
System.out.println(this.domain);
}
else
this.domain = host;
当运行ant构建时,它会显示以下错误消息:
When running ant to build, it gives such error message:
[javac] symbol : method name()
[javac] location: class com.google.common.net.InternetDomainName
[javac] this.domain = domainName.topPrivateDomain().name();
[javac] ^
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
方法 topPrivateDomain
返回一个 InternetDomainName
对象,它有一个名为 name()
的方法。有什么问题?
the method topPrivateDomain
returns a InternetDomainName
object and it do has a method called name()
. What's the problem?
推荐答案
InternetDomainName
没有 name()
方法。它直到15.0,但在16.0被删除。使用 toString()
。
InternetDomainName
does not have a name()
method. It did up until 15.0, but it was removed in 16.0. Use toString()
.
这篇关于使用Guava获取私有域名时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文