List of utility methods to do Path File Move mio
Path | move(Path from, Path to) Move source file into target file if the target file exists, then the target file is replaced. return Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
|
void | move(Path source, Path destination) Attempts to move the file represented by the specified Path to the specified destination atomically, resorting to moving it non-atomically if atomic operations are not supported by the source or destination file system. try { Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); } catch (AtomicMoveNotSupportedException e) { Files.move(source, destination, StandardCopyOption.REPLACE_EXISTING); |
void | moveDirectory(Path srcPath, Path destPath) move Directory if (!srcPath.toFile().isDirectory()) { throw new IOException(srcPath.toAbsolutePath().toString() + " is not a directory!"); if (!destPath.toFile().exists()) { destPath.toFile().mkdirs(); Files.move(srcPath, destPath, StandardCopyOption.REPLACE_EXISTING); |
void | moveFile(Path from, Path to) move File Files.move(from, to, StandardCopyOption.REPLACE_EXISTING); |
void | moveFile(Path source, Path target) Moves the file from source to target. try { Files.move(source, target); } catch (Exception ex) { throw new RuntimeException( "Can not move the source file " + source.toString() + " to target " + target.toString(), ex); |
void | moveFile(Path source, Path target, boolean prompt) move File CopyOption[] options = new CopyOption[] { REPLACE_EXISTING }; if (!prompt || Files.notExists(target)) try { Files.move(source, target, options); } catch (IOException x) { System.err.format("Unable to copy: %s: %s%n", source, x); |
void | moveFile(Path tempPath, Path defPath) move File try { Files.move(tempPath, defPath, StandardCopyOption.REPLACE_EXISTING); } catch (FileAlreadyExistsException faee) { throw new FileAlreadyExistsException(defPath.toString(), tempPath.toString(), "File already exists: " + defPath); } catch (IOException ex) { throw new IOException("Can't move " + tempPath + " to " + defPath + ".", ex); |
void | moveFile(String pathBefore, String pathAfter) move File copyFile(pathBefore, pathAfter); deleteFile(pathBefore); |
void | moveFile(String workspacePathOld, String workspacePathNew) move File createFoldersIfNecessary(workspacePathNew); Path pathOld = FileSystems.getDefault().getPath(workspacePathOld); Path pathNew = FileSystems.getDefault().getPath(workspacePathNew); Files.move(pathOld, pathNew); |