class="java" name="code">package com.file; import java.io.File; public class IteratorFile { public static void main(String[] args) { File file = new File("F:\\"); fileNameList(file.listFiles()); } private static void fileNameList(File[] file) { if(file == null)return; for(File file1 : file) { if(file1.isDirectory()) { fileNameList(file1.listFiles()); } else { System.out.println(file1.getName()); } } } }