public static void main(String[] args) { // TODO Auto-generated method stub File f = new File("D://360压缩"); mothod(f); } public static void mothod(File f){ if (f.isFile() || !f.exists()){ return; } File[] files = f.listFiles(); for(File Fs : files){ if (Fs.isFile()){ System.out.println("文件:"+Fs.getName()); }else{ System.out.println("目录:"+Fs.getName()); mothod(Fs); } } }
来源:https://www.cnblogs.com/rzkwz/p/12381067.html