Java 打开失败:enoint(没有这样的文件或目录)
如果我的当前文件不存在,我尝试获取OutputStream或createNewFile,但出现异常“open failed:Enoint(没有这样的文件或目录)”。当我在android设备中检查fileManager时,我看到当前创建的文件大小为0字节。我确信那个目录是存在的。我的代码出了什么问题?谢谢Java 打开失败:enoint(没有这样的文件或目录),java,android,Java,Android,如果我的当前文件不存在,我尝试获取OutputStream或createNewFile,但出现异常“open failed:Enoint(没有这样的文件或目录)”。当我在android设备中检查fileManager时,我看到当前创建的文件大小为0字节。我确信那个目录是存在的。我的代码出了什么问题?谢谢 final File fileBackupDir = new File(Environment.getExternalStorageDirectory(), "/Pioneers Sourc
final File fileBackupDir = new File(Environment.getExternalStorageDirectory(), "/Pioneers Source/" + "/DownLoad/temp.apk");
if (!fileBackupDir.exists())
{
try {
fileBackupDir.createNewFile();
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(fileBackupDir));
} catch (IOException e)
{
e.printStackTrace();
}
}
您有一个双/at“先锋源/下载”
更换
final File fileBackupDir = new File(Environment.getExternalStorageDirectory(), "/Pioneers Source/" + "/DownLoad/temp.apk");
至
final File fileBackupDir = new File(Environment.getExternalStorageDirectory(), "/Pioneers Source/" + "DownLoad/temp.apk");
已在清单上添加权限<代码>/“+”/…=?是的,使用此清单这里的
字符串串联的原因是什么?尽可能避免字符串连接,为了提高性能(因为它们太离谱了),我用最终文件fileBackupDir=new File(Environment.getExternalStorageDirectory(),“/preoners Source/DownLoad/temp.apk”),但是你有那些文件夹吗?如果不是,你也需要创建这些