I have a URL string where I need to replace the last collection of characters after the final "/"
In Ruby, this would be:
str = "/some/url/structure"
ar = str.split("/")
ar[ar.length-1] = "path"
string = ar.join("/")
>> "/some/url/path"
How can I do this in Java?