I am trying to copy a file using the following code:
File targetFile = new File(targetPath + File.separator + filename); ... targetFile.createNewFile(); file
Try adding some logging to see exactly what is the name and path the file is trying to create, to ensure that the parent is well a directory.
In addition, you can also take a look at Channels instead of using a loop. ;-)