zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java中读取某个目录下的所有文件和文件夹详解编程语言

JAVA文件编程语言 详解 目录 所有 读取 文件夹
2023-06-13 09:11:51 时间
File[] tempList = file.listFiles(); System.out.println("该目录下对象个数:"+tempList.length); for (int i = 0; i tempList.length; i++) { if (tempList[i].isFile()) { System.out.println("文 件:"+tempList[i]); if (tempList[i].isDirectory()) { System.out.println("文件夹:"+tempList[i]); }
 for(int i=0;i array.length;i++){ 

 if(array[i].isFile()){ 

 // only take file name System.out.println("^^^^^" + array[i].getName()); // take file path and name System.out.println("#####" + array[i]); // take file path and name System.out.println("*****" + array[i].getPath()); }else if(array[i].isDirectory()){ getFile(array[i].getPath()); } } 
 } 
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19513.html

cjava