I have the following String with a file path like that:
In that case: R5X5.mps
Use regex. It's pretty straightforward:
String last = str.replaceAll(".*/", "");
This regex says "everything up and including a slash", which gets replaced by nothing (effectively "deleting" it).
I don't think anyone would use the word "building" to describe the effort required to type