ITeye博客

递归显示文件夹下文件

demojava · 2011-08-10 14:43 · JAVA · 编程语言 · Markdown

public static void main(String args) throws Exception { //递归显示C盘下所有文件夹及其中文件 File root = new File("C:\Documents and Settings\Administrator\桌面"); showAllFiles(root); }

 final static void showAllFiles(File dir) throws Exception{
  File fs = dir.listFiles();
  for(int i=0; i<fs.length; i++){
   System.out.println(fs*.getAbsolutePath());
   if(fs*.isDirectory()){
    try{
     showAllFiles(fs*);
    }catch(Exception e){}
   }
  }
}

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。