Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果值包含 http 或 https,我会在以下代码中收到 unknownhost 异常。但如果 url 以 www 开头,它会给出结果。
InetAddress.getByName(value)
为什么会这样?
Because http(or https) is the protocol, and not part of the name.
http
https
InetAddress.getByName(value) works with names only, not URLs.