java.nio.file.Path.spliterator()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中java.nio.file.Path.spliterator()方法的一些代码示例,展示了Path.spliterator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.spliterator()方法的具体详情如下:
包路径:java.nio.file.Path
类名称:Path
方法名:spliterator

Path.spliterator介绍

暂无

代码示例

代码示例来源:origin: io.github.gradle-clojure/gradle-clojure-plugin

private static String findNamespace(Path file, Set<Path> roots) {
 Path root = roots.stream()
   .filter(file::startsWith)
   .findFirst()
   .orElseThrow(() -> new IllegalStateException("No source root found for " + file.toString()));
 String fileName = file.getFileName().toString();
 Path relPath = root.relativize(file).resolveSibling(fileName.substring(0, fileName.lastIndexOf('.')));
 return StreamSupport.stream(relPath.spliterator(), false)
   .map(Path::toString)
   .map(Namespaces::demunge)
   .collect(Collectors.joining("."));
}

代码示例来源:origin: gradle-clojure/gradle-clojure

private static String findNamespace(Path file, Set<Path> roots) {
 Path root = roots.stream()
   .filter(file::startsWith)
   .findFirst()
   .orElseThrow(() -> new IllegalStateException("No source root found for " + file.toString()));
 String fileName = file.getFileName().toString();
 Path relPath = root.relativize(file).resolveSibling(fileName.substring(0, fileName.lastIndexOf('.')));
 return StreamSupport.stream(relPath.spliterator(), false)
   .map(Path::toString)
   .map(Namespaces::demunge)
   .collect(Collectors.joining("."));
}

代码示例来源:origin: com.pragmaticobjects.oo.atom/atom-basis

@Override
  public final List<String> classNames() {
    try {
      if(Files.notExists(path)) {
        return List.empty();
      }
      final List<String> classes = Files.find(path, Integer.MAX_VALUE, (p, bf) -> p.toString().endsWith(".class"))
        .map(path::relativize)
        .map(p -> List.ofAll(StreamSupport.stream(p.spliterator(), false)))
        .map(pl -> pl.map(Object::toString).collect(Collectors.joining(".")))
        .map(s -> s.replace(".class", ""))
        .filter(s -> !"module-info".equals(s))
        .collect(List.collector());
      return classes;
    } catch(Exception ex) {
      throw new RuntimeException(ex);
    }
  }
}

相关文章