URL parsing in Java

java, url, url-parsing

Solution

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());

Problem

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

Original source

Related problems