本文整理了Java中java.nio.file.Path.endsWith()
方法的一些代码示例,展示了Path.endsWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.endsWith()
方法的具体详情如下:
包路径:java.nio.file.Path
类名称:Path
方法名:endsWith
暂无
代码示例来源:origin: dreamhead/moco
@Override
public boolean apply(final Path path) {
return path.endsWith(context);
}
};
代码示例来源:origin: apache/groovy
@Override
public boolean endsWith(String other) {
return delegate.endsWith(other);
}
代码示例来源:origin: spotbugs/spotbugs
static boolean isClassFile(Path p) {
return p.endsWith(".class") && !p.endsWith("module-info.class") && Files.isRegularFile(p);
}
代码示例来源:origin: stackoverflow.com
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");
}
}
}
代码示例来源:origin: org.assertj/assertj-core
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);
}
}
代码示例来源:origin: org.assertj/assertj-core
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));
}
代码示例来源:origin: oracle/helidon
.filter(e -> FilesystemWatchPollingStrategy.this.path.endsWith((Path) e.context()))
.forEach(FilesystemWatchPollingStrategy.this::fireEvent);
代码示例来源:origin: joel-costigliola/assertj-core
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));
}
代码示例来源:origin: joel-costigliola/assertj-core
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);
}
}
代码示例来源:origin: org.assertj/assertj-core
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));
}
代码示例来源:origin: looly/hutool
for (WatchEvent<?> event : wk.pollEvents()) {
kind = event.kind();
if(null != this.filePath && false == this.filePath.endsWith(event.context().toString())){
代码示例来源:origin: looly/hutool
for (WatchEvent<?> event : wk.pollEvents()) {
kind = event.kind();
if(null != this.filePath && false == this.filePath.endsWith(event.context().toString())){
代码示例来源:origin: joel-costigliola/assertj-core
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));
}
代码示例来源:origin: OpenHFT/Chronicle-Queue
@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());
}
}
代码示例来源:origin: schemacrawler/SchemaCrawler
@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;
}
代码示例来源:origin: Netflix/hollow
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;
}
代码示例来源:origin: Netflix/hollow
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();
}
}
}
}
代码示例来源:origin: org.onap.ccsdk.sli.core/sli-common
@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;
}
代码示例来源:origin: org.wildfly.swarm/container
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;
}
}
代码示例来源:origin: OpenNMS/opennms
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;
}
}
内容来源于网络,如有侵权,请联系作者删除!