Search code examples
javastringurluri

How to remove the parameters in url Java


I have a URL when I run my project.

http://localhost:8084/blog1_1/title?uname=55%22

and I want remove the query string from this URL like below:

http://localhost:8084/blog1_1/title

Can you please suggest me how to do this?


Solution

  • String url="http://localhost:8084/blog1_1/title?uname=55%22";
    String onlyUrl=url.substring(0,url.lastIndexOf("?")); //this has the URL