Errors Using Guava to Get Private Domain Name

I am using guava-18.0 and java1.6

The codes below are:

 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 you run ant to build, it produces the following 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 topPrivateDomain method returns an InternetDomainName object, and it has a method called name() . What is the problem?

+1
guava dns ant
Nov 14 '14 at 20:06
source share
1 answer

InternetDomainName does not have a name() method. It was before 15.0, but it was removed at 16.0. Use toString() .

+4
Nov 14 '14 at 20:59
source share



All Articles