JFileChooser to open multiple txt files

前端 未结 3 1786
醉梦人生
醉梦人生 2020-12-17 09:51

How can I use JFileChooser to open two text files and after I selected these files, I want to compare them, show on the screen etc. Is this possible?

3条回答
  •  没有蜡笔的小新
    2020-12-17 10:47

    You can use:

    JFileChooser chooser = new JFileChooser();
    chooser.setMultiSelectionEnabled(true);
    
    // Show the dialog; wait until dialog is closed
    chooser.showOpenDialog(frame);
    
    // Retrieve the selected files.
    File[] files = chooser.getSelectedFiles();
    

    You can then use the file handles returned to do the compare.

提交回复
热议问题