android文件系统区分大小写的问题

    xiaoxiao2026-01-02  9

    Android File.exists()有大小写区分吗? file android

    我创建了一个新的文件 "sdcard/dd"通过:

    File album = new File(albumPath); if (album.exists()) { Log.d(TAG, albumPath + " already exists."); } else { boolean bFile = album.mkdir(); }

    然后我又用同样的方法创建了第二个文件 "sdcard/DD"。 album.exists()返回值为true,这说明 "dd" 等同于"DD". 为什么File.exists()方法不能检查出文件夹名的大小写呢?

    同问0 | 浏览5445 | 收藏0 | 分享

    2个回答

    按赞数排序  yongyong_21    2013.01.04 17:42 已采纳

    如果你有两个文件,/sdcard/file (在 SD卡)和 /data/file (在内部文件系统), 你会得到以下结果:

    new File("/sdcard/file").exists(); // true new File("/sdcard/FILE").exists(); // true, /sdcard是一个区分大小写的文件系统 new File("/data/file").exists(); // true new File("/data/FILE").exists(); // false, /数据是区分大小写的文件系统  0  1 评论 0 | 分享 Billy_崔海斌    2012.12.28 15:35

    原因在于filesystem是fat32,而fat32是不支持区分大小写的。 所以就算你判断出DD不存在,还是不能去创建DD的目录。

    原文链接: http://ask.csdn.net/questions/939
    转载请注明原文地址: https://ju.6miu.com/read-1305595.html
    最新回复(0)