I have a application which requires the user to input some values. From these values a URL is generated. However if the user enters special symbols like e.g. german vowels or other strange symbol, there is an exception when I try to create a URL. So i have two questions:
-
What is the best way to detect if a URL is a well-formed URL?
-
How should i convert a invalid URL into a valid URL? I know this want work, but I’d like if from a invalid URL a valid URL is generated that is as similar as possible to the original URL: for example http://www.äüö.com is modified to http://www.auo.com
java.net.URLin the Android Java runtime behaves much like the Sun Java class of the same name. Its constructor throws aMalformedURLExceptionif the URL is malformed.