I have developed an application that reads files from the folder chosen by the user. It displays how many lines of code are in each file. I want only Java files to be shown in t
You need a FilenameFilter. This should work for you:
FilenameFilter javaFileFilter= new FilenameFilter() {
@Override
public boolean accept(File logDir, String name) {
return name.endsWith(".java")
}
};
You should look upon Filtering the list of Files in JFileChooser.
It has an example of ImageFilter.java which shows only image files in file chooser.