jfilechooser - set directory to a path in a file

后端 未结 6 1207
一整个雨季
一整个雨季 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:19

    In your main class declare

    public static String dirpath=".";
    
    private void btnBrowseActionPerformed(java.awt.event.ActionEvent evt) {    
     JFileChooser jfc = new JFileChooser(dirpath);
     dirpath =jfc.getSelectedFile().getAbsolutePath().toString();
    }
    

提交回复
热议问题