File file1 = new File(file.getAbsoluteFile() + "/example/directory/example.png");
file1.mkdirs();
file1.setWritable(true);
file1.createNewFile();
try {
FileInputStream is = new FileInputStream(exampleInputDirectory);
FileOutputStream os = new FileOutputStream(file1);
FileChannel srcChannel = is.getChannel();
FileChannel dstChannel = os.getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
is.close();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
这是我的设置,用于将映像文件复制到新的目录树。然而,当这个代码被执行,我得到如下:复制文件导致java.io.FileNotFoundException(访问被拒绝)输出
java.io.FileNotFoundException: *points to output directory* (Access is denied)
难道我走了有关创建file1
不正确?
您在第一行'file.getAbsoluteFile()'中写道。你有另外一个名为file的变量,或者你的意思是'file1'? – Kon
是正在使用的文件?你有权访问该路径吗? – DarthVader
已经更新了答案,看看。 – Ankit