I have this string in my Android Application:
/storage/emulated/0/temp.jpg
I need manipulate the string and to split the string for this output:
temp.jpg
I need always take the last element of the string.
How to this output in java?
I would greatly appreciate any help you can give me in working this problem.
Split Names tool - fastest way to separate names in ExcelSelect any cell containing a name you want to separate and click the Split Names icon on the Ablebits Data tab > Text group. Select the desired names parts (all of them in our case) at click Split.
The Split-Path cmdlet returns only the specified part of a path, such as the parent folder, a subfolder, or a file name. It can also get items that are referenced by the split path and tell whether the path is relative or absolute. You can use this cmdlet to get or submit only a selected part of a path.
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
one another possibility:
String lStr = "/storage/emulated/0/temp.jpg";
lStr = lStr.substring(lStr.lastIndexOf("/")+1);
System.out.println(lStr);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With