Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Find {
- public static class Finder extends SimpleFileVisitor<Path>{
- private final PathMatcher matcher;
- private int numMatches = 0;
- Finder(String pattern){
- matcher = FileSystems.getDefault().getPathMatcher("glob:" + pattern);
- }
- void find(Path file){
- Path name = file.getFileName();
- System.out.println("Name " + name);
- if (name != null && matcher.matches(name)){
- numMatches++;
- System.out.println(file);
- }
- }
- void done(){
- System.out.println("Matched: " + numMatches);
- }
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs){
- find(file);
- return CONTINUE;
- }
- public interface Path
- extends Comparable<Path>, Iterable<Path>, Watchable
- System.out.println("Name " + name);
- /**
- * Returns the name of the file or directory denoted by this path as a
- * {@code Path} object. The file name is the <em>farthest</em> element from
- * the root in the directory hierarchy.
- *
- * @return a path representing the name of the file or directory, or
- * {@code null} if this path has zero elements
- */
- Path getFileName();
- String string1 = "saw I was ";
- System.out.println("Dot " + string1 + "Tod");
- Dot saw I was Tod
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement