Skip to main content

Posts

Showing posts with the label java nio

Using Files walkFileTree Method

There are several common uses of Files walkFileTree  method. 1.        Finding File import java . io . IOException ; import java . nio . file .*; import java . nio . file . attribute .*; class FileFindVisitor extends SimpleFileVisitor < Path > {     private PathMatcher matcher ;     public FileFindVisitor ( String pattern ){         try { matcher = FileSystems . getDefault (). getPathMatcher ( pattern );         } catch ( IllegalArgumentException e ) {             e . printStackTrace ();         }     }     public FileVisitResult visitFile ( Path path , BasicFileAttributes fileAttributes ){         find ( path );     ...