Java Path File Move mio moveFile(Path source, Path target, boolean prompt)

Here you can find the source of moveFile(Path source, Path target, boolean prompt)

Description

move File

License

MIT License

Declaration

private static void moveFile(Path source, Path target, boolean prompt) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w  .  ja  va  2s .  c o  m*/
 * Copyright (C) 2011-2014 by Ahmed Osama el-Sawalhy
 *
 *      The Modified MIT Licence (GPL v3 compatible)
 *          License terms are in a separate file (LICENCE.md)
 *
 *      Project/File: Overcast/com.yagasoft.overcast.base.container/FolderHelper.java
 *
 *         Modified: Apr 15, 2014 (8:06:38 AM)
 *            Using: Eclipse J-EE / JDK 7 / Windows 8.1 x64
 */

import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import java.io.IOException;
import java.nio.file.CopyOption;

import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    private static void moveFile(Path source, Path target, boolean prompt) {
        CopyOption[] options = new CopyOption[] { REPLACE_EXISTING };

        if (!prompt || Files.notExists(target)) // || okayToOverwrite(target))
        {
            try {
                Files.move(source, target, options);
            } catch (IOException x) {
                System.err.format("Unable to copy: %s: %s%n", source, x);
            }
        }
    }
}

Related

  1. move(Path from, Path to)
  2. move(Path source, Path destination)
  3. moveDirectory(Path srcPath, Path destPath)
  4. moveFile(Path from, Path to)
  5. moveFile(Path source, Path target)
  6. moveFile(Path tempPath, Path defPath)
  7. moveFile(String pathBefore, String pathAfter)
  8. moveFile(String workspacePathOld, String workspacePathNew)