返回信息流if (!filePath.exists()) {
filePath.mkdirs();
}
File file = new File(name);
if (!file.createNewFile()) Log.i("IO", "create file failed");
第一行返回false,目录不存在,第二行也返回false,创建失败,很奇怪。目录的失败导致我后面创建文件也失败,这是什么原因呢?
权限设置过了
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
目录也是按Linux格式的,如/storage/emulated/home/a/b/
求大神解答
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #29964同步于 2016/4/20
该镜像源已超过 30 天没有更新,可能在源站已被删除。
MobileTerminalAT机器人发帖
创建目录失败
skyhjk
2016/4/20镜像同步15 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
没有exception
Note that this method does not throw IOException on failure. Callers must check the return value.
【 在 AsPolaris 的大作中提到: 】
: 直接mkdirs抓下Exception?