诚心请教怎么才能读取一个文件夹内的所有文件夹名??

解决方案 »

  1.   

    File 类里面有取得文件夹内全部文件的方法,以及判断是否文件夹的方法。需要的话在使用递归
      

  2.   

    是 String[] list()方法?
      

  3.   

    private static void printAllFileName(String path){
        File file = new File(path);
        if(file.isDirectory()){
          File[] files = file.listFiles();
          for(int i = 0; i < files.length;i++){
            if(files[i].isFile()){
              System.err.println("" + file.getName());
            }else{
              printAllFileName(files[i].getPath());
            }
          }
        }else if(file.isFile()){
          System.err.println("" + file.getName());
        }  }
      

  4.   

    sorry,我上面的方法打印的是所有文件名动动脑筋自己改改吧