本文整理了Java中java.nio.file.Files.isDirectory()
方法的一些代码示例,展示了Files.isDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.isDirectory()
方法的具体详情如下:
包路径:java.nio.file.Files
类名称:Files
方法名:isDirectory
暂无
代码示例来源:origin: neo4j/neo4j
private static Path calculateArchive( String database, Path to )
{
return Files.isDirectory( to ) ? to.resolve( database + ".dump" ) : to;
}
代码示例来源:origin: springside/springside4
public static boolean isDirExists(Path dirPath) {
return dirPath != null && Files.exists(dirPath) && Files.isDirectory(dirPath);
}
代码示例来源:origin: google/guava
Path normalizedAbsolutePath = path.toAbsolutePath().normalize();
Path parent = normalizedAbsolutePath.getParent();
if (parent == null) {
if (!Files.isDirectory(parent)) {
Files.createDirectories(parent, attrs);
if (!Files.isDirectory(parent)) {
throw new IOException("Unable to create parent directories of " + path);
代码示例来源:origin: apache/storm
private void forEachTopologyDistDir(ConsumePathAndId consumer) throws IOException {
Path stormCodeRoot = Paths.get(ConfigUtils.supervisorStormDistRoot(conf));
if (Files.exists(stormCodeRoot) && Files.isDirectory(stormCodeRoot)) {
try (DirectoryStream<Path> children = Files.newDirectoryStream(stormCodeRoot)) {
for (Path child : children) {
if (Files.isDirectory(child)) {
String topologyId = child.getFileName().toString();
consumer.accept(child, topologyId);
}
}
}
}
}
代码示例来源:origin: syncany/syncany
public static boolean isDirectory(File file) {
try {
return Files.isDirectory(Paths.get(file.getAbsolutePath()), LinkOption.NOFOLLOW_LINKS);
}
catch (InvalidPathException e) {
return false;
}
}
代码示例来源:origin: GoogleContainerTools/jib
private JavaContainerBuilder addDirectory(
Path directory, AbsoluteUnixPath destination, LayerType layerType, Predicate<Path> pathFilter)
throws IOException {
if (!Files.exists(directory)) {
throw new NoSuchFileException(directory.toString());
}
if (!Files.isDirectory(directory)) {
throw new NotDirectoryException(directory.toString());
}
layerConfigurationsBuilder.addDirectoryContents(layerType, directory, pathFilter, destination);
classpath.add(destination.toString());
return this;
}
}
代码示例来源:origin: prestodb/presto
private static Path getSourcePath()
{
Path workingDir = Paths.get(System.getProperty("user.dir"));
verify(isDirectory(workingDir), "Working directory is not a directory");
String topDirectoryName = workingDir.getFileName().toString();
switch (topDirectoryName) {
case "presto-benchto-benchmarks":
return workingDir;
case "presto":
return workingDir.resolve("presto-benchto-benchmarks");
default:
throw new IllegalStateException("This class must be executed from presto-benchto-benchmarks or presto source directory");
}
}
代码示例来源:origin: google/error-prone
@Override
public boolean accept(Path entry) throws IOException {
return Files.isDirectory(entry)
|| matchPattern.matcher(entry.getFileName().toString()).matches();
}
}
代码示例来源:origin: apache/storm
private static IVersionInfo getFromClasspath(List<String> classpath, final String propFileName) {
IVersionInfo ret = null;
for (String part: classpath) {
Path p = Paths.get(part);
if (Files.isDirectory(p)) {
Path child = p.resolve(propFileName);
if (Files.exists(child) && !Files.isDirectory(child)) {
try (FileReader reader = new FileReader(child.toFile())) {
Properties info = new Properties();
代码示例来源:origin: lets-blade/blade
public void processEvent(BiConsumer<WatchEvent.Kind<Path>, Path> processor){
for(;;){
WatchKey key;
try{
key = watcher.take();
}catch (InterruptedException e) {
return;
}
Path dir = pathMap.get(key);
for (WatchEvent<?> event: key.pollEvents()){
WatchEvent.Kind kind = event.kind();
Path filePath = dir.resolve(((WatchEvent<Path>)event).context());
if(Files.isDirectory(filePath)) continue;
log.info("File {} changes detected!",filePath.toString());
//copy updated files to target
processor.accept(kind, filePath);
}
key.reset();
}
}
代码示例来源:origin: opensourceBIM/BIMserver
Path logFolder = config.getHomeDir().resolve("logs");
if (!Files.isDirectory(logFolder)) {
Files.createDirectories(logFolder);
Path file = logFolder.resolve("bimserver.log");
ple.start();
FileAppender<ILoggingEvent> fileAppender = new FileAppender<ILoggingEvent>();
String filename = file.toAbsolutePath().toString();
代码示例来源:origin: MovingBlocks/Terasology
private void handleItemSelection(String item) {
Path path = currentPath == null ? Paths.get(item) : currentPath.resolve(item);
if (Files.isDirectory(path)) {
setCurrentDirectory(path);
} else {
fileName = item;
}
}
代码示例来源:origin: apache/ignite
/**
* Answers if the given path denotes existing directory.
*
* @param path The directory path.
* @return {@code True} if the given path denotes an existing directory.
*/
public static boolean exists(String path) {
if (F.isEmpty(path))
return false;
Path p = Paths.get(path);
return Files.exists(p) && Files.isDirectory(p) && Files.isReadable(p);
}
代码示例来源:origin: pmd/pmd
public RuleDocGenerator(FileWriter writer, Path root) {
this.writer = Objects.requireNonNull(writer, "A file writer must be provided");
this.root = Objects.requireNonNull(root, "Root directory must be provided");
Path docsDir = root.resolve("docs");
if (!Files.exists(docsDir) || !Files.isDirectory(docsDir)) {
throw new IllegalArgumentException("Couldn't find \"docs\" subdirectory");
}
}
代码示例来源:origin: Graylog2/graylog2-server
final Path tmpPath = Paths.get(tmpDir);
if (!Files.isDirectory(tmpPath) || !Files.isWritable(tmpPath)) {
throw new IllegalStateException("Couldn't write to temporary directory: " + tmpPath.toAbsolutePath());
代码示例来源:origin: line/armeria
FileSystemHttpVfs(Path rootDir) {
this.rootDir = requireNonNull(rootDir, "rootDir").toAbsolutePath();
if (!Files.exists(this.rootDir) || !Files.isDirectory(this.rootDir)) {
throw new IllegalArgumentException("rootDir: " + rootDir + " (not a directory");
}
}
代码示例来源:origin: pxb1988/dex2jar
if (!Files.exists(jar)) {
System.err.println(jar + " is not exists");
usage();
if (Files.isDirectory(jar)) {
output = new File(jar.getFileName() + "-jar2dex.dex").toPath();
} else {
output = new File(getBaseName(jar.getFileName().toString()) + "-jar2dex.dex").toPath();
if (Files.exists(output) && !forceOverwrite) {
System.err.println(output + " exists, use --force to overwrite");
usage();
final Path realJar;
try {
if (Files.isDirectory(jar)) {
realJar = Files.createTempFile("d2j", ".jar");
tmp = realJar;
ps.addAll(Arrays.asList("--dex", "--no-strict", "--output=" + output.toAbsolutePath().toString(), realJar
.toAbsolutePath().toString()));
System.out.println("call com.android.dx.command.Main.main" + ps);
m.invoke(null, new Object[] { ps.toArray(new String[ps.size()]) });
代码示例来源:origin: Alluxio/alluxio
/**
* Creates a new local Alluxio master with a isolated port.
*
* @param workDirectory Alluxio work directory, this method will create it if it doesn't exist yet
* @return the created Alluxio master
*/
public static LocalAlluxioMaster create(final String workDirectory) throws IOException {
if (!Files.isDirectory(Paths.get(workDirectory))) {
Files.createDirectory(Paths.get(workDirectory));
}
return new LocalAlluxioMaster(null, null);
}
代码示例来源:origin: pxb1988/dex2jar
if (!Files.exists(jar)) {
System.err.println(jar + " is not exists");
usage();
if (Files.isDirectory(jar)) {
output = new File(jar.getFileName() + "-rechecksum.dex").toPath();
} else {
output = new File(getBaseName(jar.getFileName().toString()) + "-rechecksum.dex").toPath();
if (Files.exists(output) && !forceOverwrite) {
System.err.println(output + " exists, use --force to overwrite");
usage();
代码示例来源:origin: jooby-project/jooby
Path outdir = this.basedir.toPath().resolve("node_modules").resolve(library.replace("/", "."));
Optional<Path> basedir = Try.apply(() -> Paths.get(uri)).toOptional();
String libroot = Route.normalize("/" + library);
try (Library lib = loadLibrary(uri)) {
try (Stream<Path> stream = lib.stream()) {
stream.filter(it -> !Files.isDirectory(it))
.forEach(it -> {
String relative = basedir.map(d -> d.relativize(it).toString())
.orElseGet(() -> {
String fname = it.toString();
if (fname.startsWith(libroot)) {
fname = fname.substring(libroot.length());
Path output = outdir.resolve(relative);
File fout = output.toFile();
boolean copy = !fout.exists()
内容来源于网络,如有侵权,请联系作者删除!