【发布时间】:2013-07-21 20:17:22
【问题描述】:
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: *points to output directory* (Access is denied)
我是否错误地创建了file1?
【问题讨论】:
-
你在第一行写了
file.getAbsoluteFile()。您是否还有另一个名为 file 的变量,或者您的意思是file1? -
文件正在被使用吗?您是否有权访问该路径?
-
已更新答案,看看吧。
标签: java file filenotfoundexception access-denied