Jsleshem
Jsleshem

Reputation: 735

"Access Denied" Message when trying to copy file(s) pulled with JGit

I have some java code that goes ahead and pulls code from a git repository that I have access to. The files are properly pulled locally.

When I try to copy the files with the Files.copy() method in java.io.file from one local destination to another, I get the following error thrown:

java.io.FileNotFoundException: C:\Some\Path\dir (Access is denied)

I have already added the following code in attempt to change the file permissions:

fileInitialLocation.setReadable(true, false);
fileInitialLocation.setExecutable(true, false);
fileInitialLocation.setWritable(true, false);

fileFinalLocation.setReadable(true, false);
fileFinalLocation.setExecutable(true, false);
fileFinalLocation.setWritable(true, false);

What can I change to properly copy the files from the initial location to the final location to prevent the access denied error?

Upvotes: 0

Views: 1052

Answers (1)

Eugen
Eugen

Reputation: 917

You need to provide the file name when copying.

File fileForCopy = new File("C:\Some\Path\dir\fileName.txt");

If you need to copy whole folder try Apache Commons IO FileUtils.

Upvotes: 2

Related Questions