public static void snail(String fpath) {
    File tmpf=new File(fpath);
    if (tmpf.isDirectory()) {
      try {
        //System.out.println("-- Begin --\n");
        String[] c=tmpf.list();
        if ((c!=null) && (c.length!=0)) {
          for (int i=0;i<c.length;i++) {
            String tmp_path=fpath+"/"+c[i];
            File tf=new File(tmp_path);
            if (tf.isDirectory()) {
              snail(tmp_path);
            } else {
              //totals++;
              //判断规则
              int tail=c[i].length();
              if ((c[i].indexOf('A')==0)&&(c[i].substring(tail-4,tail).equals(".TXT"))) //匹配A*.TXT(区分大小写!)
                System.out.println("-> "+tmp_path);
            }
          }
        }
        //System.out.println("\n-- End --");
      }
      catch (Exception e) {
        //System.out.println("-- ERROR --");
        e.printStackTrace();
      }
    }
  }

解决方案 »

  1.   

    就是用了个递归 ... 还有, 这是在win2000下试的,我用的是'/'不是'\\',也没错,hehehe :)
      

  2.   

    to Dureek
        一定要用算法来实现吗,是否可用listFiles(FileFilter filter)函数.
      

  3.   

    public 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. The behavior of this method is the same as that of the listFiles() method, except that the pathnames in the returned array must satisfy the filter. If the given filter is null then all pathnames are accepted. Otherwise, a pathname satisfies the filter if and only if the value true results when the FilenameFilter.accept(java.io.File, java.lang.String) method of the filter is invoked on the pathname综上所述,看来是可以的
      

  4.   

    5555555 ... 我不知道有这个好东西的 :~(谢谢ljd和Mar_lee的指点 ^^
      

  5.   

    5555555 ... 我不知道有这个好东西的 :~(谢谢ljd和Mars_lee的指点 ^^
      

  6.   

    5555555 ... 我不知道有这个好东西的 :~(谢谢ljd和Mars_lee的指点 ^^
      

  7.   

    to Dureek:
         是我在求教,哪敢说指点 ^^
      

  8.   

    我只是c & p ,hehe