List of utility methods to do Path File Name nio
Path | getPathByFormat(String nameBeforeDot, String nameAfterDot, Path parent, int i, String date) get Path By Format Path renamed; String fileName = String.format(FILE_NAME_FORMAT, nameBeforeDot, date, i, nameAfterDot); if (parent == null) { renamed = Paths.get(fileName); } else { renamed = parent.resolve(fileName); return renamed; ... |
String | getPathCleanName(Path object) get Path Clean Name return object.getFileName().toString().replaceAll("\\..*", ""); |
Path | getPathInTmpDir(String fileName) get Path In Tmp Dir return Paths.get(TMP_DIR + "/" + fileName); |
String | GetPathName(String path) Get Path Name return Path2UnixStr(Paths.get(path).getFileName());
|
Path | getPathOfClass(Class cls, String filename) get Path Of Class URL uri = cls.getResource(filename);
return uri == null ? null : Paths.get(uri.getFile());
|
Path | getPathProperty(Properties props, String propName) Gets a property (in Path) from config.properties String strValue; Path path; try { strValue = getProperty(props, propName); } catch (Exception e) { throw e; try { ... |
List | getPaths(Path dir, String fileNames) get Paths List<Path> paths = new ArrayList<>(); DirectoryStream<Path> directories = Files.newDirectoryStream(dir); for (Path path : directories) { if (!Files.isDirectory(path)) { continue; Path file = path.resolve(fileNames); if (!Files.exists(file)) { ... |
String | getPrefix(final Path file, final int filenameSuffixLength) Get part of filename before given suffix assert file != null; final Path fileName = file.getFileName(); if (fileName == null) { throw new IllegalArgumentException("Invalid file (no filename, probably root?): " + file); final String filename = fileName.toString(); return filename.substring(0, filename.length() - filenameSuffixLength); |
PrintWriter | getPrintWriter(String className, String flushPath) get Print Writer File root = new File(flushPath); String path = root.getAbsolutePath() + File.separator + className + ".java"; File classFile = prepareFile(path); try { return new PrintWriter( new OutputStreamWriter(new FileOutputStream(classFile), Charset.defaultCharset())); } catch (Exception e) { e.printStackTrace(); ... |
List | getProvenanceLogFiles(final String baseName, final Collection get Provenance Log Files final List<File> matchingFiles = new ArrayList<>(); final String searchString = baseName + "."; for (final Path path : allProvenanceLogs) { if (path.toFile().getName().startsWith(searchString)) { final File file = path.toFile(); if (file.exists()) { matchingFiles.add(file); } else { ... |