File的
 String[] list()
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
 String[] list(FilenameFilter filter)
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
 File[] listFiles()
          Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
 File[] listFiles(FileFilter filter)
          Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
 File[] listFiles(FilenameFilter filter)
          Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

解决方案 »

  1.   

    严重同意楼上的顺便问一句有没有像theFile那样的控件可以用来导入整个文件夹中所有文件?而不必要用多个theFile来实现一次上传多个文件的?
      

  2.   

    File pa=new File("目录名");
    String[] cc=pa.list();
    for(int i=0;i<cc.length;i++)
      System.out.println(cc[i]);
      

  3.   

    String url1="C:/aaa";
    File[] file=(new File(url1)).listFiles();
     for(int i=0;i<file.length;i++){
      if(file[i].isFile()){
       file[i].toString();
    out.println((file[i].getName()).toString());
     }
    }
      

  4.   

    用遍历做。
    File f = new File("c:/");
        File[] sub =  f.listFiles();
        for(int i =0;i<sub.length;i++){
          if(sub[i].isDirectory() ){continue;}
             System.out.println(sub[i]);
        }
      

  5.   

    得到所有文件名,然后lastIndexOf(".");就可以把后缀名截取出来,然后就是比较罗!
    留下符合的即可!
    int i=FileName.lastIndexOf(".");
    String houzhui=FileName.substring(i+1);
      

  6.   

    String[] strs = file.list( new FilenameFilter(){
      public boolean accept(File dir,String name){
        return name.endsWith( suffix );
      }
    });