All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.carlspring.commons.io.FileUtils Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
package org.carlspring.commons.io;

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

/**
 * @author mtodorov
 */
public class FileUtils
{

    public static void moveDirectory(Path srcPath, Path destPath)
            throws IOException
    {
        if (!srcPath.toFile().isDirectory())
        {
            throw new IOException(srcPath.toAbsolutePath().toString() + " is not a directory!");
        }

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

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy