Sunny Sunny - 2 years ago 110
Java Question

Java: Getting a substring from a string starting after a particular character

I have a string:


I would like to extract
from this this, ie, the substring after the last "/" or first "/" from right.

Could someone please provide some help?

Answer Source
    String example = "/abc/def/ghfj.doc";
    System.out.println(example.substring(example.lastIndexOf("/") + 1));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download