java.io.FileNotFoundException: 由于文件名中的某些错误,无法创建文件,仅在某些设备中遇到此错误,例如:android 4.1.2

1 android filenotfoundexception

File external = getExternalFilesDir(null);

//fd is stringbuffer whose value is "year1:semester:2"

File file = new File(external,""+fd.toString()+".txt"); // <----error

FileOutputStream fos = new FileOutputStream(file);
fos.write(store.getBytes());
fos.close();
Run Code Online (Sandbox Code Playgroud)

这是生成的异常:

W/System.err(29169): java.io.FileNotFoundException: /storage/sdcard0/Android/data/com.example.ddu/files/Year:1Semester:2.txt: open failed: EINVAL (Invalid argument)
Run Code Online (Sandbox Code Playgroud)

Abd*_*tir 5

您不能创建具有结肠文件(在它的名字)。用其他东西替换冒号。