You want something like this:
String path = new URL("http://www.costo.com/test1/test2").getPath();
Actually that’ll give you /test1/test2
. You’ll just have to remove the first /
to get what you want:
path = path.replaceFirst("https://stackoverflow.com/", "");
Now you’ll have test1/test2
in path
.