str = str.substring(0, str.length() - 1);
String example = "/abc/def/ghfj.doc"; System.out.println(example.substring(example.lastIndexOf("/") + 1));