android - 文件名字符导致打开失败 : EINVAL (Invalid argument)

标签 android

我想用以下格式的文件名创建一个文件:DAY-MONTH-YEAR--HOUR:MINUTE 但是当我使用 -- 或/and : 我遇到了 open failed: EINVAL 异常。我试图摆脱这些焦炭,但没有快乐。是否有任何禁止的文件名字符列表?

   String time = String.valueOf(c.get(Calendar.DAY_OF_MONTH)) + "-" + String.valueOf(c.get(Calendar.MONTH) + 1) + "-" +
               String.valueOf(c.get(Calendar.YEAR)) + "--" + String.valueOf(c.get(Calendar.HOUR)) + "\\:" + String.valueOf(c.get(Calendar.MINUTE));

 bufOutstream = new BufferedOutputStream(new FileOutputStream(new File(env.getExternalStorageDirectory()+"/myapp/"+time+"."+fExtension)));

日志:

12-01 10:34:01.181  25839-26542/com.example.app W/System.err﹕ Caught IOException: /storage/sdcard0/myapp/1-12-2013--10\:34.aac: open failed: EINVAL (Invalid argument)

最佳答案

请参阅此页面,您将找到完整列表。

http://en.wikipedia.org/wiki/Comparison_of_file_systems

虽然你的 sdcard 可能是内部的并且挂载为 FUSE,它可能仍然是 FAT32 文件系统。 FAT32 的有效字符是(根据页面):

除值 0-31、127 (DEL) 和 " * / : < > ? \ | + , . ; = [] 之外的任何字节(小写 a-z 存储为 A-Z )。使用 VFAT LFN 任何 Unicode,除了 NUL

关于android - 文件名字符导致打开失败 : EINVAL (Invalid argument),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20310904/

相关文章:

javascript - 当我点击其他地方时如何隐藏我的滑动sidenav?

android - Jenkins:无法创建 Android 模拟器,无法解析 AVD 配置文件

java - android studio 媒体播放器 null 对象引用

android - 在带有 Eclipse 的 android 上使用 gdb 调试 native 代码 (C++)。是否可以?

java - Android Espresso 测试 : Illegal class access: 'androidx.test.core.app.ListFuture' attempting to access 'androidx.concurrent.futures.DirectExecutor'

android - 将 onListItemClick 与数据驱动的 ListView 一起使用

android - 正确使用 TextUtils.commaEllipsize

android - 将项目符号与包装的 TextView 的第一行对齐

android - 是否可以在 Android 中从 xml 更改 Material 设计图标颜色?

android - 如何从 Linux 命令行为 Flutter 应用程序生成 SHA-1