-5

That is my code to the JFileChooser to select a file now i want to select multiple file what to do

JFileChooser chose=new JFileChooser();
chose.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int r=chose.showOpenDialog(new JFrame());
if(r == chose.APPROVE_OPTION){
    String filepath= chose.getSelectedFile().getAbsolutePath();
}

how to select a multiple file using JFileChooser Please Help...

Renish Khunt
  • 5,620
  • 18
  • 55
  • 92
  • 2
    There are at least two duplicates of this question, please try Googleing before asking! http://stackoverflow.com/questions/11922152/jfilechooser-to-open-multiple-txt-files http://stackoverflow.com/questions/13060371/adding-multiple-files-with-jfilechooser – devrobf Apr 26 '13 at 12:06

2 Answers2

11

chose.setMultiSelectionEnabled(true)

Tadas S
  • 1,955
  • 19
  • 33
4

Try this:

JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
chooser.showOpenDialog(frame);
File[] files = chooser.getSelectedFiles();
Alya'a Gamal
  • 5,624
  • 19
  • 34