I am currently calling the following line of code:
java.net.URL connection_url = new java.net.URL("http://<ip address>:<port>/path");
and I get the exception above when it executes. Any ideas as to why this is happening?
Handling MalformedURLException The only Solution for this is to make sure that the url you have passed is legal, with a proper protocol. The best way to do it is validating the URL before you proceed with your program. For validation you can use regular expression or other libraries that provide url validators.
Class MalformedURLExceptionThrown to indicate that a malformed URL has occurred. Either no legal protocol could be found in a specification string or the string could not be parsed.
This violation indicates that a request that was not created by a browser, and does not comply with HTTP standards, has been sent to the server. This may be the result of of an HTTP request being manually crafted or of a client tunneling other protocols over HTTP.
As a side note, you should be using URI because Java URL class is screwed up. (The equals method I believe)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With