1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import org.apache.commons.io.FileUtils; import java.io.File; import java.io.IOException; public class DirectoryMove { public static void main(String[] args) { String source = "C:/Demo/source"; File srcDir = new File(source); String destination = "C:/Demo/target"; File destDir = new File(destination); try { // // Move the source directory to the destination directory. // The destination directory must not exists prior to the // move process. // FileUtils.moveDirectory(srcDir, destDir); } catch (IOException e) { e.printStackTrace(); } } } |