当我在 Nexus 5 上运行该应用程序时,该文件没有问题,但在另一台智能手机上我遇到了问题,我认为可能是空格,我将其删除。
代码是:
File file = new File(directory,new SimpleDateFormat("dd-MM-yyyy-HH:mm:ss",Locale.ROOT).format(new Date()).toString()+"-"+idUser+"-"+idTest+".txt");
FileOutputStream outputStream = new FileOutputStream(file);
路径文件:/storage/sdcard0/Nexio/Tests/23-07-2014-16:33:11-alex-0.txt
目录存在。异常(exception)是“FileNotFoundException”
最佳答案
您可能正在使用静态字符串设置目录..那是我的猜测..使用 http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()
关于android - 创建文件android时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24913485/