How to split a file path to get the file name?
one another possibility:
String lStr = "/storage/emulated/0/temp.jpg";
lStr = lStr.substring(lStr.lastIndexOf("/")+1);
System.out.println(lStr);
This is not a string splitting exercise
If you need to get a file name from a file path, use the File
class:
File f = new File("/storage/emulated/0/temp.jpg");
System.out.println(f.getName());
Output:
temp.jpg