|
|
|
|
|
by deepsun
2383 days ago
|
|
I actually like it. I also create my own exceptions for rare (exceptional) cases, just not to forget to handle them. But some Java SDK exceptions drive me crazy. For example `URL.parse("http://example.com")` over hard-coded strings that I know 100% won't throw exceptions, but I still to catch 3 of them. |
|
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.