Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public class Find {
  2. public static class Finder extends SimpleFileVisitor<Path>{
  3. private final PathMatcher matcher;
  4. private int numMatches = 0;
  5.  
  6. Finder(String pattern){
  7. matcher = FileSystems.getDefault().getPathMatcher("glob:" + pattern);
  8. }
  9.  
  10. void find(Path file){
  11. Path name = file.getFileName();
  12. System.out.println("Name " + name);
  13. if (name != null && matcher.matches(name)){
  14. numMatches++;
  15. System.out.println(file);
  16. }
  17. }
  18.  
  19. void done(){
  20. System.out.println("Matched: " + numMatches);
  21. }
  22.  
  23. @Override
  24. public FileVisitResult visitFile(Path file, BasicFileAttributes attrs){
  25. find(file);
  26. return CONTINUE;
  27. }
  28.  
  29. public interface Path
  30. extends Comparable<Path>, Iterable<Path>, Watchable
  31.  
  32. System.out.println("Name " + name);
  33.  
  34. /**
  35. * Returns the name of the file or directory denoted by this path as a
  36. * {@code Path} object. The file name is the <em>farthest</em> element from
  37. * the root in the directory hierarchy.
  38. *
  39. * @return a path representing the name of the file or directory, or
  40. * {@code null} if this path has zero elements
  41. */
  42. Path getFileName();
  43.  
  44. String string1 = "saw I was ";
  45. System.out.println("Dot " + string1 + "Tod");
  46.  
  47. Dot saw I was Tod
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement