2

How can I move a folder to another. Like the ctrl + x function in windows.

So i want to copy myfoldertocopy which contains files and folders to another destination:

C:\Users\myfoldertocopy
To
D:\data\

So i tried it with

public static void moveFolder(File source, File target){
    try {
        Files.move(source.toPath(), target.toPath().resolve(source.toPath().getFileName()));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

but i throws an DirectoryNotEmptyException. So how i can move the complete myfoldertocopy with ALL content to another location?
Need i to iterate over it, or am i just using the move-method wrong?

Ronon
  • 738
  • 10
  • 26

0 Answers0