I got a strange behavior of that method:
import java.net.URI
URI url = new URI("https://pmi_artifacts_prod.s3.amazonaws.com");
System.out.println(url.getHost()); /returns NULL
URI url2 = new URI("https://s3.amazonaws.com");
System.out.println(url2.getHost()); //returns s3.amazonaws.com
`
i want first url.getHost()
to be pmi_artifacts_prod.s3.amazonaws.com, but it gives me NULL. Turned out that problem is with underscores in domain name, its a known bug, but still what can be done as I need to work with this host exactly?
https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_hostnames
Underscore support could be added right into URI by patching:
No, the result is absolutely coming right. Kindly go through the documentation for
url.getHost()
Java docs says :
To add to this answer, if using eclipse kindly jump to the method definition (press f3) you will get your answer.