Java Path Copy nio copyContents(Path from, Path to)

Here you can find the source of copyContents(Path from, Path to)

Description

copy Contents

License

Apache License

Declaration

public static void copyContents(Path from, Path to) 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;

public class Main {
    public static void copyContents(Path from, Path to) throws IOException {
        if (to == null || from == null)
            return;
        if (Files.exists(to))
            Files.delete(to);/* www .  j a  v a  2  s  .  c  o m*/
        if (!from.toFile().renameTo(to.toFile()))
            throw new IOException("Could not move " + from.toFile().getPath() + " to " + to.toFile().getPath());
        if (Files.exists(from))
            Files.delete(from);
    }
}

Related

  1. copy(String filePath, String fileName)
  2. copyAlways(Path source, Path target)
  3. copyAsTrueTempFile(Path source, FileAttribute... attrs)
  4. copyConfigFile(final String file, final Path dir)
  5. copyContainer(String from, String to, IProgressMonitor monitor)
  6. copyEverythingExcept(Path file, Path srcDir, Path dstDir, Predicate excluded, Consumer onCopy)
  7. copyFile(final String fileName, final String from, final String to)
  8. copyFile(InputStream from, Path to)
  9. copyFile(Path from, Path to)