@Override public boolean apply(final Path path) { return path.endsWith(context); } };
@Override public boolean endsWith(String other) { return delegate.endsWith(other); }
final Path path = FileSystems.getDefault().getPath(System.getProperty("user.home"), "Desktop"); System.out.println(path); try (final WatchService watchService = FileSystems.getDefault().newWatchService()) { final WatchKey watchKey = path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY); while (true) { final WatchKey wk = watchService.take(); for (WatchEvent<?> event : wk.pollEvents()) { //we only register "ENTRY_MODIFY" so the context is always a Path. final Path changed = (Path) event.context(); System.out.println(changed); if (changed.endsWith("myFile.txt")) { System.out.println("My file has changed"); } } // reset the key boolean valid = wk.reset(); if (!valid) { System.out.println("Key has been unregisterede"); } } }
public void assertEndsWith(final AssertionInfo info, final Path actual, final Path end) { assertNotNull(info, actual); assertExpectedEndPathIsNotNull(end); try { final Path canonicalActual = actual.toRealPath(); if (!canonicalActual.endsWith(end.normalize())) throw failures.failure(info, shouldEndWith(actual, end)); } catch (IOException e) { throw new PathsException(FAILED_TO_RESOLVE_ACTUAL_REAL_PATH, e); } }
public void assertHasFileName(final AssertionInfo info, Path actual, String fileName) { assertNotNull(info, actual); checkNotNull(fileName, "expected fileName should not be null"); if (!actual.getFileName().endsWith(fileName)) throw failures.failure(info, shouldHaveName(actual, fileName)); }
.filter(e -> FilesystemWatchPollingStrategy.this.path.endsWith((Path) e.context())) .forEach(FilesystemWatchPollingStrategy.this::fireEvent);
public void assertHasFileName(final AssertionInfo info, Path actual, String fileName) { assertNotNull(info, actual); checkNotNull(fileName, "expected fileName should not be null"); if (!actual.getFileName().endsWith(fileName)) throw failures.failure(info, shouldHaveName(actual, fileName)); }
public void assertEndsWith(final AssertionInfo info, final Path actual, final Path end) { assertNotNull(info, actual); assertExpectedEndPathIsNotNull(end); try { final Path canonicalActual = actual.toRealPath(); if (!canonicalActual.endsWith(end.normalize())) throw failures.failure(info, shouldEndWith(actual, end)); } catch (IOException e) { throw new PathsException(FAILED_TO_RESOLVE_ACTUAL_REAL_PATH, e); } }
public void assertEndsWithRaw(final AssertionInfo info, final Path actual, final Path end) { assertNotNull(info, actual); assertExpectedEndPathIsNotNull(end); if (!actual.endsWith(end)) throw failures.failure(info, shouldEndWith(actual, end)); }
for (WatchEvent<?> event : wk.pollEvents()) { kind = event.kind(); if(null != this.filePath && false == this.filePath.endsWith(event.context().toString())){
for (WatchEvent<?> event : wk.pollEvents()) { kind = event.kind(); if(null != this.filePath && false == this.filePath.endsWith(event.context().toString())){
public void assertEndsWithRaw(final AssertionInfo info, final Path actual, final Path end) { assertNotNull(info, actual); assertExpectedEndPathIsNotNull(end); if (!actual.endsWith(end)) throw failures.failure(info, shouldEndWith(actual, end)); }
@Test public void shouldBeAbleToLoadQueueFromReadOnlyFiles() throws Exception { if (OS.isWindows()) { System.err.println("#460 Cannot test read only mode on windows"); return; } final File queueDir = getTmpDir(); try (final ChronicleQueue queue = builder(queueDir, wireType). testBlockSize().build()) { queue.acquireAppender().writeDocument("foo", (v, t) -> { v.text(t); }); } Files.list(queueDir.toPath()).filter(p -> p.endsWith(SingleChronicleQueue.SUFFIX)).forEach(p -> assertTrue(p.toFile().setWritable(false))); try (final ChronicleQueue queue = builder(queueDir, wireType). readOnly(true). testBlockSize().build()) { assertTrue(queue.createTailer().readingDocument().isPresent()); } }
@Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { for (final String filename: new String[] { serverFileStem + ".lck", serverFileStem + ".log", serverFileStem + ".lobs", serverFileStem + ".script", serverFileStem + ".properties" }) { if (!attrs.isDirectory() && file.endsWith(filename)) { delete(file); } } return FileVisitResult.CONTINUE; }
protected HollowAPIGenerator(String apiClassname, String packageName, HollowDataset dataset, Set<String> parameterizedTypes, boolean parameterizeAllClassNames, boolean useErgonomicShortcuts, Path destinationPath) { this.apiClassname = apiClassname; this.packageName = packageName; this.dataset = dataset; this.hasCollectionsInDataSet = hasCollectionsInDataSet(dataset); this.parameterizedTypes = parameterizedTypes; this.parameterizeClassNames = parameterizeAllClassNames; this.ergonomicShortcuts = useErgonomicShortcuts ? new HollowErgonomicAPIShortcuts(dataset) : HollowErgonomicAPIShortcuts.NO_SHORTCUTS; if (destinationPath != null && packageName != null && !packageName.trim().isEmpty()) { Path packagePath = Paths.get(packageName.replace(".", File.separator)); if (!destinationPath.toAbsolutePath().endsWith(packagePath)) { destinationPath = destinationPath.resolve(packagePath); } } this.destinationPath = destinationPath; }
public void generateFiles(File directory) throws IOException { Path destinationPath = directory.toPath(); Path packagePath = Paths.get(packageName.replace(".", File.separator)); if (!destinationPath.toAbsolutePath().endsWith(packagePath)) { destinationPath = destinationPath.resolve(packagePath); } directory = destinationPath.toFile(); if (!directory.exists()) directory.mkdirs(); for (HollowSchema schema : dataset.getSchemas()) { if (schema instanceof HollowObjectSchema && !isPrimitiveType(schema.getName())) { HollowPOJOClassGenerator generator = new HollowPOJOClassGenerator(dataset, (HollowObjectSchema) schema, packageName, pojoClassNameSuffix); FileWriter writer = new FileWriter(new File(directory, generator.getClassName() + ".java")); writer.write(generator.generate()); writer.close(); } } } }
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { String[] skipDirectories = {".git"}; for (String str : skipDirectories) { if (dir.endsWith(str)) { return FileVisitResult.SKIP_SUBTREE; } } return CONTINUE; }
public static String archiveNameForClassesDir(Path path) { if (path.endsWith(TARGET_CLASSES)) { // Maven return path.subpath(path.getNameCount() - 3, path.getNameCount() - 2).toString() + JAR; } else if (path.endsWith(BUILD_CLASSES_MAIN) || path.endsWith(BUILD_RESOURCES_MAIN)) { // Gradle + Gradle 4+ return path.subpath(path.getNameCount() - 4, path.getNameCount() - 3).toString() + JAR; } else { return UUID.randomUUID().toString() + JAR; } }
private void processStoreByGroupResources(final Path path) { try { // Find and process all resource folders containing a 'ds.properties' file Files.walk(path) .filter(p -> p.endsWith("ds.properties")) .forEach(p -> processStoreByGroupResource(p.getParent())); } catch (Exception e) { LOG.error("Error while reading RRD files", e); return; } }