List of utility methods to do Path Copy nio
void | createDirectoriesIfNeeded(Path directory) Creates the specified directory if it does not exists. if (!Files.exists(directory)) {
Files.createDirectories(directory);
|
Path | createDirectoriesIfNotExists(Path path) create Directories If Not Exists if (Files.exists(path)) { return path; return Files.createDirectories(path); |
boolean | createDirectory(Path directory) create Directory try { if (!Files.exists(directory)) { Files.createDirectories(directory); return true; } catch (IOException e) { return false; |
void | createDirectory(Path outDir, boolean cleanExisting) create Directory if (cleanExisting) {
cleanDirectory(outDir);
Files.createDirectories(outDir);
|
Path | createDirectory(Path parent, String name) Creates the directory with name in the parent directory parent Path result = null; try { if (name != null) { result = parent.resolve(name); } else { result = parent; if (!Files.exists(result)) { ... |
void | createDirectoryIfNotExists(Path path) Check specified directory. try { Files.createDirectories(path); } catch (FileAlreadyExistsException ignored) { |
void | createDirectoryRecursively(Path dir) Attempts to create a directory given a String path. try { Files.createDirectories(dir); } catch (IOException e) { throw new IOException("Exception while trying to create directory: " + e); if (!dir.toFile().exists()) { throw new IOException("Failed to verify directory creation - directory does not exist."); |
void | createDirectoryRecursively(String dirName) create Directory Recursively Path newDirectoryPath = Paths.get(dirName); if (Files.exists(newDirectoryPath)) { throw new java.nio.file.FileAlreadyExistsException("directory " + dirName + " already exists"); Files.createDirectories(newDirectoryPath); |
boolean | renameTo(Path from, Path to, CopyOption... options) rename To try { return Files.move(from, to, options) != null; } catch (IOException e) { return false; |
void | write(InputStream in, Path path, StandardCopyOption op) write. try { Files.copy(in, path, op); } catch (IOException e) { throw new RuntimeException(e); |