【问题标题】:errors when using Guava to get the private domain name使用 Guava 获取私有域名时出错
【发布时间】:2014-11-14 20:06:41
【问题描述】:

我正在使用guava-18.0java1.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构建时,报错如下:

[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() 的方法。有什么问题?

【问题讨论】:

    标签: ant dns guava


    【解决方案1】:

    InternetDomainName 没有name() 方法。它一直到 15.0,但在 16.0 中被删除。使用toString()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-26
      • 2023-03-13
      • 1970-01-01
      • 2013-03-02
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多