Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Core Java Code Examples

List all '.java' files present in a directory.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
List all '.java' files present in a directory. import java.io.*; public class FileExt { public static void main(String args[]) { try { String[] filesList; File dir = new File("."); filesList= dir.list(new FileFilter()); for (int i=0;i { System.out.println(filesList[i]); } } catch(Exception e){} } } class FileFilter implements FilenameFilter { public boolean accept(File dir, String name) { return (name.endsWith(".java")); } }