I am searching a way for parsing URL/URIs in Java without having to worry about Exceptions for common URLs. The Java integrated way I know are using java.net.URI
respectively java.net.URL
.
Each of these classes have major draw backs:
java.net.URL
can not handle custom protocols/schemes and fails therefore with URLs likeidontcare://bla.com/test
java.net.URI
has no problems with custom protocols/schemes but it fails if for example the query part contains an "illegal character" (a special character that is not URL encoded). Therefor it failes for example in an URL likehttps://bla.example.org/css?family=Roboto:300|Roboto:300,400,500,700&lang=de
Is there a universal and non-resticted (does not throw errors for cases as presented above) way to parse URLs in Java?