从完整文件路径查找文件名 [英] Find file name from full file path
本文介绍了从完整文件路径查找文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法从文件完整路径(文件路径的一部分)中提取文件名,而不用麻烦操纵字符串?
Is there a way to extract the file name from the file full path (part of a file path) without the hassle of manipulating string?
Java中的等效项将是:
The equivalent in Java would be:
File f = new File ("C:/some_dir/a")
f.getName() //output a
f.getFullAbsolutePath() //output c:/some_dir/a
推荐答案
使用
> basename("C:/some_dir/a.ext")
[1] "a.ext"
> dirname("C:/some_dir/a.ext")
[1] "C:/some_dir"
这篇关于从完整文件路径查找文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文