List of utility methods to do Path File List nio
void | loadTrainingData(Path path, List load Training Data List<String> lines = Files.readAllLines(path); Collections.shuffle(lines, new Random(System.nanoTime())); for (int i = 0; i < lines.size(); i++) { String[] pieces = lines.get(i).split("\\s"); float[] tmpInput = new float[pieces.length - outputCount]; float[] tmpOutput = new float[outputCount]; for (int k = 0; k < pieces.length - outputCount; k++) { tmpInput[k] = Float.parseFloat(pieces[k]); ... |
void | mergeFiles(List merge Files try (FileChannel out = FileChannel.open(mergedFile, StandardOpenOption.APPEND, StandardOpenOption.WRITE)) { for (Path path : files) { try (FileChannel in = FileChannel.open(path, StandardOpenOption.READ)) { for (long p = 0, l = in.size(); p < l;) p += in.transferTo(p, l - p, out); } catch (IOException e) { ... |
void | mergeInto(List Merge the given part files in order into an output stream. for (final Path part : parts) { Files.copy(part, out); Files.delete(part); |
Predicate | pathContainsAny(List path Contains Any return path -> { boolean included = strings.stream() .anyMatch(wildcardMatcher -> path.toString().contains(wildcardMatcher)); return included; }; |
Set | recursiveListFiles(Path file) recursive List Files Set<Path> files = new HashSet<Path>(); files.add(file); if (file.toFile().isDirectory()) { for (File child : file.toFile().listFiles()) { files.addAll(recursiveListFiles(child.toPath())); return files; ... |
void | recusivelyCollectFileListing(ArrayList recusively Collect File Listing try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(directory)) { for (Path path : directoryStream) { if (Files.isDirectory(path)) { recusivelyCollectFileListing(rc, base, path); } else { rc.add(base.relativize(path).toString()); |
void | registerRecursive(final WatchService watcher, final List Register the given directory, and all its sub-directories, with the WatchService. for (Path start : startingPaths) { Files.walkFileTree(start, new SimpleFileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { register(watcher, dir); return FileVisitResult.CONTINUE; }); ... |
List | retrieveTokenFilesInDirImportableFrom(Path dir, List retrieve Token Files In Dir Importable From assert dir != null; List<String> answer = new ArrayList<>(); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**/*.tokens"); try (DirectoryStream<Path> filePathStream = Files.newDirectoryStream(dir);) { Iterator<Path> iterator = filePathStream.iterator(); while (iterator.hasNext()) { Path path = iterator.next(); if (matcher.matches(path)) { ... |
String | toCliString(Path agentPath, String param) to Cli String if (param != null && !param.isEmpty()) { return "-javaagent:" + agentPath.toString() + "=" + param; } else { return "-javaagent:" + agentPath.toString(); |
void | toFile(Path file, String list) to File FileOutputStream fos = null; try { fos = new FileOutputStream(file.toString()); fos.write(list.getBytes()); fos.flush(); } finally { if (fos != null) fos.close(); ... |