1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Java.nio.file - Copying files

Discussion in 'Programming & Webmastering' started by Wozzer, Apr 12, 2012.

  1. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.48/day)
    Thanks Received:
    68
    Location:
    England
    Can anyone tell me what I've done wrong with the following code. I receive no errors - it just goes straight to the catch.

     
  2. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.48/day)
    Thanks Received:
    68
    Location:
    England
    I should also note that the following errors appear when I print the stack.

    Code:
    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)
     
  3. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.48/day)
    Thanks Received:
    68
    Location:
    England
    problem solved
     
  4. temp02 New Member

    Joined:
    Mar 18, 2009
    Messages:
    493 (0.23/day)
    Thanks Received:
    166
    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
     
    Wozzer says thanks.
  5. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,881 (4.83/day)
    Thanks Received:
    5,619
    Location:
    Cheeseland (Wisconsin, USA)
    Please post the fix, Wasley, so others can benefit if they run across this issue.
     
  6. Wozzer

    Joined:
    Jun 30, 2008
    Messages:
    1,133 (0.48/day)
    Thanks Received:
    68
    Location:
    England
    Issue was the above, so thanks temp02.
     
    Kreij says thanks.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page