How to filter selection of files by extension in Java Swing’s JFileChooser

Display of files of a particular extension like .txt or .csv in JFileChooser can be done using the FileNameExtensionFilter in Java as follows:

fileChooser = new JFileChooser();
fileChooser.setSelectedFile(null);
FileNameExtensionFilter fileFilter = new FileNameExtensionFilter(“CSV Files”, “csv”);
fileChooser.setFileFilter(fileFilter);
fileChooser.showOpenDialog(frame);

Leave a Reply

  

  

  

Blue Captcha Image
Refresh

*

September 2019
M T W T F S S
« Aug    
 1
2345678
9101112131415
16171819202122
23242526272829
30