errors when using Guava to get the private domain name

♀尐吖头ヾ 提交于 2019-12-11 11:05:20

问题


I am using guava-18.0 and java1.6

Given codes below:

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;

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

the method topPrivateDomain returns a InternetDomainName object and it do has a method called name(). What's the problem?


回答1:


InternetDomainName does not have a name() method. It did up until 15.0, but it was removed in 16.0. Use toString().



来源:https://stackoverflow.com/questions/26938002/errors-when-using-guava-to-get-the-private-domain-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!