Java Utililty Methods Path Create nio

List of utility methods to do Path Create nio

Description

The list of methods to do Path Create nio are organized into topic(s).

Method

FilegetOrCreateDir(Path path)
get Or Create Dir
if (path == null) {
    return null;
File file = path.toFile();
if (!file.exists()) {
    file.mkdirs();
return file;
...
booleanisTempCreatedFile(Path filePath)
is Temp Created File
String fileName = String.valueOf(filePath.getFileName());
if ((fileName.startsWith("~$")
        || ((fileName.startsWith("~") || fileName.startsWith("ppt") || fileName.startsWith("pub"))
                && fileName.endsWith(".tmp")))
        && !Files.isDirectory(filePath)) {
    return true;
Matcher matcher = _tempCreatedFilePattern.matcher(String.valueOf(filePath.getFileName()));
...
voidsetTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime, Path... files)
Set files times.
for (Path file : files) {
    BasicFileAttributeView view = Files.getFileAttributeView(file, BasicFileAttributeView.class);
    view.setTimes(lastModifiedTime, lastAccessTime, createTime);
PathtoPath(@Nullable String plain)
to Path
return plain != null ? Paths.get(plain) : null;
PathtoPath(String first, String... more)
to Path
return FileSystems.getDefault().getPath(first, more);
PathtoPath(String path)
to Path
return Paths.get(path);
PathtoPath(String uri, Path root)
Computes a full path for a URI within a
String relative = stripLeadingSlash(uri);
return root.resolve(relative);
PathtoPath(String value, Path defaultValue)
to Path
if (value == null || value.length() == 0) {
    return defaultValue;
return Paths.get(value);
Path[]toPathArray(File... files)
Converts the given array of files into an array of paths
Path[] paths = new Path[files.length];
int idx = 0;
for (File file : files) {
    paths[idx++] = file.toPath();
return paths;
IterabletoPaths(File... files)
Converts the given files to a sequence of paths.
List<Path> paths = new ArrayList<>(files.length);
for (File file : files) {
    paths.add(file.toPath());
return paths;