Advertisement
andylai

SimpleFileVisitor

Aug 21st, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1.  
  2. public class Searchapp extends SimpleFileVisitor{
  3.  
  4. @override
  5. public FileVisitResult visitFile(Path file, BasicFileAttributes attrs){
  6.  
  7. PathMatcher matcher=FileSystems.getDefult().getPathMatcher("glob:*.{html,java}");
  8. Path name=file.getFileName();
  9. if(name!=null&& matcher.match(name)) System.out.println(file);
  10. return FileVisitorResult.CONTINUE;
  11.  
  12. }
  13.  
  14. public static void main(String[] args) {
  15.      
  16. Files.walkFileTree(Path.get("c:/temp"),new Searchapp());
  17.     }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement