Prints the path of all. java files under the specified directory and subdirectories. (using FileFilter Filter)

Source: Internet
Author: User

1  Packagetest;2 /*3 * Print the path of all. java files under the specified directory and sub-directories.4  * */5 ImportJava.io.*;6 ImportJava.util.*;7 8  Public classTest149 {Ten      Public Static voidMain (string[] args) One     { AFile dir =NewFile ("C:\\users\\dell\\workspaces\\myeclipse 10"); -list<file> list =NewArraylist<file>(); -FileFilter FileFilter =NewFileFilter () the         { -              Public BooleanAccept (File pathname) -             { -                 if(Pathname.getname (). EndsWith (". Java")) +                     return true; -                 if(Pathname.isdirectory ()) +                     return true; A                 Else at                     return false; -             } -         }; - Method (Dir.listfiles (filefilter), list, filefilter); -          for(File file:list) - System.out.println (file); in     } -      Public Static voidMethod (file[] files, list<file>list, FileFilter filefilter) to     { +          for(File f:files) -         { the             if(F.isdirectory ()) * Method (F.listfiles (filefilter), list, filefilter); $             ElsePanax Notoginseng List.add (f); -         } the     } +}

Prints the path of all. java files under the specified directory and subdirectories. (using FileFilter Filter)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.