URI - getHost returns null. Why?

前端 未结 5 2041
春和景丽
春和景丽 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:31

    I don't think it's a bug in Java, I think Java is parsing hostnames correctly according to the spec, there are good explanations of the spec here: http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names and here: http://www.netregister.biz/faqit.htm#1

    Specifically hostnames MUST NOT contain underscores.

提交回复
热议问题