# Java.nio.file - Copying files



## Wozzer (Apr 12, 2012)

Can anyone tell me what I've done wrong with the following code. I receive no errors - it just goes straight to the catch.



> import java.io.IOException;
> import java.nio.file.Files;
> import java.nio.file.Path;
> import java.nio.file.Paths;
> ...


----------



## Wozzer (Apr 12, 2012)

I should also note that the following errors appear when I print the stack.


```
java.nio.file.NoSuchFileException: C:\Users\Public\Pictures\SamplePictures at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) at sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:99) at sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:277) at java.nio.file.Files.copy(Files.java:1219) at Main.main(Main.java:14)
```


----------



## Wozzer (Apr 12, 2012)

*problem solved*


----------



## temp02 (Apr 12, 2012)

You can't copy a folder, thats why it generates an exception (you are trying to copy a folder using a copy file function).
You probably need to list all the files inside that folder and copy one by one


----------



## Kreij (Apr 12, 2012)

Please post the fix, Wasley, so others can benefit if they run across this issue.


----------



## Wozzer (Apr 14, 2012)

temp02 said:


> You can't copy a folder, thats why it generates an exception (you are trying to copy a folder using a copy file function).
> You probably need to list all the files inside that folder and copy one by one



Issue was the above, so thanks temp02.


----------

