Package org.drasyl.util
Class UrlUtil
java.lang.Object
org.drasyl.util.UrlUtil
Utility class for operations on
URL
s.-
Method Summary
-
Method Details
-
createUrl
Creates aURL
by parsing the given string.This convenience factory method works as if by invoking the
URL(String)
constructor; anyMalformedURLException
thrown by the constructor is caught and wrapped in a newIllegalArgumentException
object, which is then thrown.This method is provided for use in situations where it is known that the given string is a legal URL, for example for URL constants declared within a program, and so it would be considered a programming error for the string not to parse as such. The constructors, which throw
MalformedURLException
directly, should be used in situations where a URL is being constructed from user input or from some other source that may be prone to errors.- Parameters:
str
- The string to be parsed into a URL- Returns:
- The new URL
- Throws:
IllegalArgumentException
- if no protocol is specified, or an unknown protocol is found, orspec
isnull
, or the parsed URL fails to comply with the specific syntax of the associated protocol.
-