URI - getHost returns null. Why?

前端 未结 5 2008
春和景丽
春和景丽 2021-01-04 03:36

Why is the 1st one returning null, while the 2nd one is returning mail.yahoo.com?

Isn\'t this weird? If not, what\'s the logic behind this

5条回答
  •  情话喂你
    2021-01-04 04:33

    Consider using: new java.net.URL("http://broken_arrow.huntingtonhelps.com").getHost() instead. It has alternative parsing implementation. If you have an URI myUri instance, then call myUri.toURL().getHost().

    I faced this URI issue in OpenJDK 1.8 and it worked fine with URL.

提交回复
热议问题