如何拆分文件路径以获取文件名? [英] How to split a file path to get the file name?

查看:91
本文介绍了如何拆分文件路径以获取文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android应用程序中有此字符串:

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.

如何在Java中输出此结果?

How to this output in java?

对于您在解决此问题方面所能提供的帮助,我将不胜感激.

I would greatly appreciate any help you can give me in working this problem.

推荐答案

另一种可能性:

String lStr = "/storage/emulated/0/temp.jpg";
lStr = lStr.substring(lStr.lastIndexOf("/")+1);
System.out.println(lStr);

这篇关于如何拆分文件路径以获取文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆