可以提供一個我函數,不過一個路徑下怎會有相同文件名呢﹖  
public ArrayList listDir(String path_str) {
    File path = new File(path_str);
    ArrayList dir_array=new ArrayList();
    String[] list;
    list = path.list();
    if (list != null) {
      for (int j = 0; j < list.length; j++) {
        String absolutePath = path.getAbsolutePath();
        absolutePath = absolutePath  + list[j];
        dir_array.add(absolutePath);
      }
    }
    return dir_array;
  }

解决方案 »

  1.   

    不是共同的名字,是名字都有共同的部分...比如都有company_info。就是company_info_microsoft,还有company_info_oracle.是这样。
      

  2.   

    absolutePath是絕對路徑。
    我那個方法不行嗎﹖
    如果有子目录的话,就需要写一个递归到每一层目录去找.
      

  3.   

    不是不行,我还没试,呵呵。我不知道绝对路径和abstract path的区别?谁有空告诉我以下啊?
      

  4.   

    有abstract path這個名詞嗎﹖
    我想你可能搞錯了。要是有也應該表示相對路徑吧
      

  5.   

    public long getFileCount(File directory) throws IOException {
    long value = 0;
    if (!directory.exists()) {
    String message = "directory not exists";
    throw new FileNotFoundException(message);
    }
    File[] files = directory.listFiles();
    for(int i = 0;i<files.length;i++) {
    if (files[i].isFile()) {
    value++;
    }
    else if(files[i].isDirectory()) {
    value += getFileCount(files[i]);
    }
    }
    return value;
    }