chooser=new JFileChooser();
         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  int n = chooser.showOpenDialog(p1 );
  if(n==JFileChooser.APPROVE_OPTION)  
                  {
    sourceroot=chooser.getSelectedFile().getAbsolutePath();
    opentext.setText(sourceroot);
                  }
这个方面先选择我所需要的目录,当前的需求是想读取目录里的所有子目录下的所需文件,昨天 shine333(enihs)朋友给了下面的方法:
File[] files = yourSelectedFile.listFiles(new FileFilter() {  
      public boolean accept(File pathname) {
        return !pathname.isDirectory();
      }
    });
但是使用之后抛出了文件拒绝访问的异常,现在应该怎么处理,请各位大侠帮忙,谢谢