@Override public DirectoryStream<Path> newDirectoryStream( final Path dir, final DirectoryStream.Filter<Path> filter ) throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException { return Files.newDirectoryStream( dir, filter ); }
@Override public DirectoryStream<Path> newDirectoryStream( final Path dir ) throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException { return Files.newDirectoryStream( dir ); }
/** * @throws IllegalArgumentException * @throws NotDirectoryException * @throws IOException * @throws SecurityException * @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newDirectoryStream(java.nio.file.Path)">Original JavaDoc</a> */ public static DirectoryStream<Path> newDirectoryStream( final Path dir ) throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException { checkNotNull( "dir", dir ); return newDirectoryStream( dir, new DirectoryStream.Filter<Path>() { @Override public boolean accept( Path entry ) throws IOException { return true; } } ); }
public static DirectoryStream<Path> newDirectoryStream( final Path dir, final String glob ) throws IllegalArgumentException, UnsupportedOperationException, PatternSyntaxException, NotDirectoryException, IOException, SecurityException { checkNotNull( "dir", dir ); checkNotEmpty( "glob", glob ); final String regex = globToRegex( glob ); final Pattern pattern = Pattern.compile( regex ); return newDirectoryStream( dir, new DirectoryStream.Filter<Path>() { @Override public boolean accept( final Path entry ) throws IOException { if ( entry.getFileName() == null ) { if ( glob.equals( "/" ) ) { return true; } return false; } if ( pattern.matcher( entry.getFileName().toString() ).find() ) { return true; } return false; } } ); }
public Builder( final Path moduleDirectory, final String artifactId, final Paths paths, final IOService ioService, final ProjectService projectService, final DirectoryStream.Filter<Path> filter ) { this.moduleDirectory = moduleDirectory; this.artifactId = artifactId; this.paths = paths; this.ioService = ioService; this.projectService = projectService; this.filter = filter; projectPrefix = moduleDirectory.toUri().toString(); kieServices = KieServices.Factory.get(); kieFileSystem = kieServices.newKieFileSystem(); DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream = Files.newDirectoryStream( moduleDirectory ); visitPaths( directoryStream ); }
private void visitPaths( final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream ) { for ( final org.kie.commons.java.nio.file.Path path : directoryStream ) { if ( Files.isDirectory( path ) ) { visitPaths( Files.newDirectoryStream( path ) ); } else if ( filter.accept( path ) ) { final String destinationPath = path.toUri().toString().substring( projectPrefix.length() + 1 ); final InputStream is = ioService.newInputStream( path ); final BufferedInputStream bis = new BufferedInputStream( is ); kieFileSystem.write( destinationPath, KieServices.Factory.get().getResources().newInputStreamResource( bis ) ); handles.put( destinationPath, paths.convert( path ) ); } } }
final DirectoryStream<Path> paths = Files.newDirectoryStream( pathToSearch ); for ( final Path path : paths ) { if ( Files.isRegularFile( path ) ) {
stream = Files.newDirectoryStream(file); } catch (IOException ex) { return visitor.visitFileFailed(file, ex);