public static void printDirsAndFiles() { printDirsAndFiles(".");}public static void printDirsAndFiles(String path) { getFile(new File(path));}public static File getFile(File file) { if (file.exists()) { if (file.isDirectory()) { System.out.println(file.getName()+"\\"); if (file.canExecute()) { for (File f : file.listFiles()) { getFile(f); } } else { System.out.println("输入的文件夹不可操作"); } }else{ System.out.println(" "+file.getName()); } return file; } else { System.out.println("输入的目录或者文件不存在!"); return null; }}
Sign in to make a reply
不可掉头--麥子