|
|
|
|
|
by twic
2373 days ago
|
|
That's why URI has a factory method that you're only supposed to use for known strings (although of course this can't be checked): https://docs.oracle.com/javase/7/docs/api/java/net/URI.html#... After URI appeared in 1.4, the only reason to use URL was to create a URLConnection from a URI. Since openConnection() throws IOException, it's not a big deal that toURL() throws a MalformedURLException - just catch it along with all the other IOExceptions. Since 11, there's no reason to use URL at all, because you can use HttpClient to actually do HTTP. |
|
The JDK is filled with a ton of dumb "once upon a time we thought this was okay..." things that don't properly encode the correct modern idiom