FileUtils.copyDirectory() error with thumbs.db/desktop.ini (Access denied) java

1.2k views Asked by At

I'm trying to copy a folder full of .txt and .jpg files into a separate folder.

From: C:/Folder/resources/

To: C:/Folder/backup/resources

public void backup() throws IOException
{
    FileUtils.copyDirectory(new File(SOURCE), new File(DESTINATION));
}

Upon calling the method, everything gets copied over, but I get a FileNotFoundException for desktop.ini and thumbs.db, it switches between the two. Using the apache.commons.io and I was wondering if anyone can point me in the right direction on how to solve the Exception. Since everything is copied over, should I just put it in a try catch block and move on or is there a solution? The SOURCE = the from path and the DESTINATION = the to path. Should they not be new Files?

java.io.FileNotFoundException: C:\Folder\resources\desktop.ini (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.commons.io.FileUtils.doCopyFile(FileUtils.java:1069)
at org.apache.commons.io.FileUtils.doCopyDirectory(FileUtils.java:1358)
at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1319)
at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1191)
at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1160)

Thanks!

0

There are 0 answers