Java 打开失败:enoint(android 6中没有此类文件或目录
我想下载我的项目的链接 我无法提交正确的位置,因此出现此错误Java 打开失败:enoint(android 6中没有此类文件或目录,java,android,Java,Android,我想下载我的项目的链接 我无法提交正确的位置,因此出现此错误 open failed: ENOENT (No such file or directory) 首先我搜索了一下,我知道我在android 6或更高版本中遇到了这个问题。我的代码在android 5中正常工作。我发现很多关于运行时权限的东西,在android 6中我需要运行时权限,所以我尝试检查我的权限并请求它们。但当我检查权限时,它表明我已经拥有这些权限锡安。 所以这种方式是不对的。 这是我的代码: public void ru
open failed: ENOENT (No such file or directory)
首先我搜索了一下,我知道我在android 6或更高版本中遇到了这个问题。我的代码在android 5中正常工作。我发现很多关于运行时权限的东西,在android 6中我需要运行时权限,所以我尝试检查我的权限并请求它们。但当我检查权限时,它表明我已经拥有这些权限锡安。
所以这种方式是不对的。
这是我的代码:
public void run() {
try {
URL url = new URL(mission.url);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
mission.length = conn.getContentLength();
if (mission.length <= 0) {
mission.errCode = DownloadMission.ERROR_SERVER_UNSUPPORTED;
//mission.notifyError(DownloadMission.ERROR_SERVER_UNSUPPORTED);
return;
}
// Open again
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Range", "bytes=" + (mission.length - 10) + "-" + mission.length);
if (conn.getResponseCode() != 206) {
// Fallback to single thread if no partial content support
mission.fallback = true;
if (DEBUG) {
Log.d(TAG, "falling back");
}
}
if (DEBUG) {
Log.d(TAG, "response = " + conn.getResponseCode());
}
mission.blocks = mission.length / BLOCK_SIZE;
if (mission.threadCount > mission.blocks) {
mission.threadCount = (int) mission.blocks;
}
if (mission.threadCount <= 0) {
mission.threadCount = 1;
}
if (mission.blocks * BLOCK_SIZE < mission.length) {
mission.blocks++;
}
new File(mission.location).mkdirs();
new File(mission.location + "/" + mission.name).createNewFile();
RandomAccessFile af = new RandomAccessFile(mission.location + "/" + mission.name, "rw");
af.setLength(mission.length);
af.close();
mission.start();
} catch (Exception e) {
// TODO Notify
throw new RuntimeException(e);
}
}
这一行:
new File(mission.location + "/" + mission.name).createNewFile();
throw new RuntimeException(e);
我检查此路径,发现它存在:
mission.location + "/" + mission.name
有什么帮助吗?
我现在有两个问题:
1.我的问题是否与许可有关?如果是,我必须在哪里检查它们(我在我的第一个活动中检查)
2.虽然我的道路是正确的,但为什么我会有这个错误
open failed: ENOENT (No such file or directory)
想下载与我的项目相关的链接。但我遇到了以下错误:open failed:enoint(没有这样的文件或目录)
。你的问题与下载文件无关。你的问题是你无法在文件系统中创建文件。请调整你的帖子,因为现在它非常混乱。请删除所有不相关的代码。我告诉过你,这在android 5中是正确的。我试着解释simpleSImple如果你只有一条语句,那么它就是s创建一个文件。好的,现在我将编辑它,这是我的问题了,