I've got the URL like this:
http://test.com/testapp/test.do?test_id=1&test_name=SS
Is there any way we can get only this part
/test.do?test_id=1&test_name=SS
URL Parsing. The URL parsing functions focus on splitting a URL string into its components, or on combining URL components into a URL string.
URL(String protocol, String host, int port, String file, URLStreamHandler handler):
The url. parse() method takes a URL string, parses it, and it will return a URL object with each part of the address as properties. Parameters: This method accepts three parameters as mentioned above and described below: urlString: It holds the URL string which needs to parse.
Use java.net.URL
to parse a url string:
URL url = new URL("http://test.com/testapp/test.do?test_id=1&test_name=SS");
System.out.println(url.getPath()+"?"+url.getQuery());
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