Basically, I have these strings:
/path/to/Pbox01/file1_#$%encryp
/path/to/Pbox01/file4_#$%encryp
/path/to/Pbox02/file2_#$%encryp
And I want to get ONLY file1
, file4
, file2
for each iteration. Those are filenames, and they can be anything(like file
, stack
, blahblahblah
. First I want to get the part after the last slash - this is the part I'm having biggest problems with. The ending is hardset, so I want to trim _#$%encryp, which is 10 characters - for that I'll use:
public String removeLastChar(String s) {
if (s == null || s.length() == 0) {
return s;
}
return s.substring(0, s.length()-10);
}
So, to summarize, the question is: How can I get the part of the string after the last /
?