List of utility methods to do Path Create nio
File | getOrCreateDir(Path path) get Or Create Dir if (path == null) { return null; File file = path.toFile(); if (!file.exists()) { file.mkdirs(); return file; ... |
boolean | isTempCreatedFile(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())); ... |
void | setTimes(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); |
Path | toPath(@Nullable String plain) to Path return plain != null ? Paths.get(plain) : null;
|
Path | toPath(String first, String... more) to Path return FileSystems.getDefault().getPath(first, more);
|
Path | toPath(String path) to Path return Paths.get(path);
|
Path | toPath(String uri, Path root) Computes a full path for a URI within a String relative = stripLeadingSlash(uri);
return root.resolve(relative);
|
Path | toPath(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; |
Iterable | toPaths(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; |