List of utility methods to do Path File List nio
void | addNonEmptyLinesFromFile(final ArrayList add Non Empty Lines From File final List<String> lines = Files.readAllLines(Paths.get(path), StandardCharsets.UTF_8);
lines.stream().filter(s -> s.length() > 0).forEach(result::add);
|
PathMatcher | anyPathMatcher(final ImmutableList A PathMatcher that returns true if any of the delegate pathMatchers returns true. return new PathMatcher() { @Override public boolean matches(Path path) { for (PathMatcher pathMatcher : pathMatchers) { if (pathMatcher.matches(path)) { return true; return false; @Override public String toString() { return "anyOf[" + Joiner.on(", ").join(pathMatchers) + "]"; }; |
void | archive(Path archive, List Archives a list of target files into a ZIP archive byte[] buffer = new byte[bufferSize]; try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(archive.toFile()))) { for (Path file : targetFiles) { ZipEntry ze = new ZipEntry(file.getFileName().toString()); zos.putNextEntry(ze); try (FileInputStream in = new FileInputStream(file.toFile())) { int len; while ((len = in.read(buffer)) > 0) { ... |
List | asFileList(Object... paths) as File List List<File> files = new ArrayList<File>(paths.length); for (Object it : paths) { if (it instanceof CharSequence) { files.add(new File(it.toString())); } else if (it instanceof File) { files.add((File) it); } else if (it instanceof Path) { files.add(((Path) it).toFile()); ... |
List | asPathsList(final File[] files) Convert an array of java.io.File to a List of java.nio.file.Path return Optional.ofNullable(files)
.map(fs -> Arrays.stream(fs).map(File::toPath).collect(Collectors.toList()))
.orElse(Collections.EMPTY_LIST);
|
boolean | compileTreeWithErrors(JavaCompiler compiler, List compile Tree With Errors return compileTreeWithErrors(compiler, options, targetFolder, diagnosticListener, false,
addProcessorsToClasspath);
|
Set | deepListChildren(Path directory) deep List Children return deepListChildren(directory, DEFAULT_GLOB);
|
ArrayList | fileListDeep(Path dir) file List Deep try { if (Files.exists(dir)) { Stream<Path> ds = Files.walk(dir); ArrayList<Path> dirList = new ArrayList<Path>(); Iterator<Path> it = ds.iterator(); while (it.hasNext()) { Path tp = it.next(); if (!Files.isDirectory(tp)) { ... |
Path | findExpectedResultForTestcase(final Path testcase, final LinkedList find Expected Result For Testcase final String fileName = getFileName(testcase); final Iterator<Path> it = expectedResults.iterator(); while (it.hasNext()) { final Path result = it.next(); if (fileName.equalsIgnoreCase(getFileName(result))) { it.remove(); return result; return null; |
ClassLoader | getClassLoaderFromPaths(ArrayList get Class Loader From Paths ArrayList<URL> urls = new ArrayList<URL>(); for (Path p : paths) { try { URL url = p.toUri().toURL(); urls.add(url); } catch (MalformedURLException e) { e.printStackTrace(); URL[] urlsArray = new URL[urls.size()]; urlsArray = urls.toArray(urlsArray); ClassLoader cl = new URLClassLoader(urlsArray); return cl; |