从奇巧文档的URI获取文件名 [英] Get fileName from uri on KitKat Document

查看:103
本文介绍了从奇巧文档的URI获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个URI获取文件名...我可以从像画廊或其他第三方文件管理器其他应用一个完整路径,但我不能从奇巧文档获得文件名,我并不需要一个完整路径只是有一个InputStream文件名是为我好...

I want to get fileName from a uri... I can get a fullpath from Other apps like gallery or other third party file managers, but I can't get fileName from KitKat Document, I don't need a fullPath just the fileName with an inputStream is good for me...

感谢

编辑:我发现了一张code,几乎解决了这个问题,但它不能获得未知类型,如文件路径* .EXE *的.vcf,...

I found a piece of code that solves the issue almost, but it can't get filePath of none known types like *.exe *.vcf , ...

这里的<一个href=\"https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java\"相对=nofollow>来源

推荐答案

如果你有文件的绝对路径,然后simpley创建文件的对象,并使用GetName方法

If you have the absolute path of file then simpley create the object of file and use getName method

File f = new File(<Full Path of your file>);

这将返回文件名以扩展。

This will return file name with extension.

如果你不希望延长
然后使用 CommonsI / O libarary

和从该库可以使用

String fileNameWithOutExt = FilenameUtils.removeExtension(fileNameWithExt);

这篇关于从奇巧文档的URI获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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