import java.io.File; public class getFileName { public static void main(String[] args) throws Exception { String filePath = "F:/eye/";//文件夹路径 getFiles(filePath); } public static void getFiles(String filePath){ File root = new File(filePath); File[] files = root.listFiles(); for(File file:files){ //递归 if(file.isDirectory()){ getFiles(file.getAbsolutePath()); }else{ String a = file.getAbsolutePath(); System.out.println(a.substring(a.lastIndexOf("\\")+1)); } } } }
获取文件夹内所有的文件名
猜你喜欢
转载自www.cnblogs.com/c-l-w/p/9760595.html
今日推荐
周排行