jfilechooser - set directory to a path in a file

后端 未结 6 1130
一整个雨季
一整个雨季 2021-02-19 05:35

I am trying to set the directory path in JFilechooser through something like this(using commons-io ) :

String fileContents = IOUtils.toString(new FileInputStream         


        
6条回答
  •  醉话见心
    2021-02-19 06:06

    For select the last directory that you open :

    chooser.setCurrentDirectory(lastDirectory);
    
    int r = chooser.showOpenDialog(new JPanel());
    
    if (r == JFileChooser.APPROVE_OPTION) {
       fileName = chooser.getSelectedFile().getPath();
       lastDirectory = chooser.getSelectedFile();
    }
    

提交回复
热议问题