相关疑难解决方法(0)

在Android中保存文件,文件名中包含空格

我需要我的android应用程序将xml文件保存到外部缓存中,文件名包含空格.

DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File(activity
                    .getExternalCacheDir().getAbsolutePath()
                    + "/Local storage.xml"));

transformer.transform(source, result);
Run Code Online (Sandbox Code Playgroud)

当我手动浏览到我的文件目录时,我找到了这个文件:"Local%20storage.xml".

所以在我尝试阅读之后

File localStorageXmlFile = new File(activity.getExternalCacheDir()
                .getAbsolutePath()
                + "/Local storage.xml");
Run Code Online (Sandbox Code Playgroud)

但是我有一个FileNotFoundException,因为在我的设备上找不到文件"Local storage.xml".

任何解决这个问题的想法?勒布

java android filenotfoundexception

5
推荐指数
1
解决办法
5640
查看次数

标签 统计

android ×1

filenotfoundexception ×1

java ×1