需求:读取指定目录下的文件名和目录名 实现如下: package com.test.common.util; import java.io.File; public class ReadFile { /* * 读取指定路径下的文件名和目录名 */ public void getFileList() { File file = new File("D:\\"); File[] fileList = file.listFiles(); for (int i = 0; i < file
import java.io.File; public class Test1 { public static void main(String[] args) { String path="d:/"; File file=new File(path); File[] tempList = file.listFiles(); System.out.println("该目录下对象个数:"+tempList.length); for (int i = 0; i <