Skip to content
Advertisement

How to copy an entire content from a directory to another in Java?

JavaScript

This is what I have. It copies everything just fine. But among the contents there are some folders. The folders are copied but the folder’s contents are not.

Advertisement

Answer

Recursion. Here is a method the uses rescursion to delete a system of folders:

JavaScript

Didn’t test the code, but it should work. Basically, it digs down into the folders, telling it to move the item, if its a folder, go through all its children, and move them, etc.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement