public class Solution {
    public static List<String> getFileTree(String root) throws IOException {
        List<String> listFiles = new ArrayList<>();
        File folder = new File(root);
        Queue<File> queue = new LinkedList<>();
        queue.offer(folder);
        for (File file : folder.listFiles()) {
            if (file.isDirectory()) {
                queue.offer(file);
            }
        }
        for (int i = 0; i < queue.size(); ) {
            for (File file : queue.poll().listFiles()) {
                if (file.isFile()) {
                    listFiles.add(file.getName());
                }
            }
        }
        return listFiles;
    }
    public static void main(String[] args) throws IOException {
        String root = new String("c:\\test\\");
        getFileTree(root);
    }
}