MalformedURLException is common exception classes in java when working with a network and is thrown from an application to indicate that a malformed URL has occurred. It happens when the built-in class URL gets an invalid URL.

In a client-server architecture, while connecting, if we use java.net.URL class object then we need to pass the String representation of URL. (This is while establishing a connection.) A MalformedURLException(Class MalformedException in Java) is thrown when “no legal protocol could be found in a specification String” or when the provided “String could not be parsed”. This is as per specification. As modern java supports most of the String manipulation statements via String commands,