我在java中编写了一个函数来将图像从一个目录复制到另一个似乎不起作用的目录。它抛出一个IOException
ie C:\Documents and Settings\Admin\Desktop\C.V (Access is denied)
。可能是什么问题呢。这是代码片段:
public void copyImageFiles(File sourceFile, File destinationDir) throws IOException {
FileInputStream fis = new FileInputStream(sourceFile);
FileOutputStream fos = new FileOutputStream(destinationDir);
FileChannel srcChannel = fis.getChannel();
FileChannel destChannel = fos.getChannel();
srcChannel.transferTo(0, sourceFile.length(), destChannel);
srcChannel.close();
destChannel.close();
fis.close();
fos.close();
}