Java Path File Move mio moveDirectory(Path srcPath, Path destPath)

Here you can find the source of moveDirectory(Path srcPath, Path destPath)

Description

move Directory

License

Apache License

Declaration

public static void moveDirectory(Path srcPath, Path destPath) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

public class Main {
    public static void moveDirectory(Path srcPath, Path destPath) throws IOException {
        if (!srcPath.toFile().isDirectory()) {
            throw new IOException(srcPath.toAbsolutePath().toString() + " is not a directory!");
        }/*  ww w.  j a va  2s.c  om*/

        if (!destPath.toFile().exists()) {
            //noinspection ResultOfMethodCallIgnored
            destPath.toFile().mkdirs();
        }

        Files.move(srcPath, destPath, StandardCopyOption.REPLACE_EXISTING);
    }
}

Related

  1. move(Path from, Path to)
  2. move(Path source, Path destination)
  3. moveFile(Path from, Path to)
  4. moveFile(Path source, Path target)
  5. moveFile(Path source, Path target, boolean prompt)
  6. moveFile(Path tempPath, Path defPath)