public class Solution { public static List<String> getFileTree(String root) throws IOException { List<String> results = new ArrayList<String>(); File file = new File(root); if(file.isDirectory()){ File[] files = new File(root).listFiles(); //If this pathname does not denote a directory, then listFiles() returns null. for (File file1 : files) { if (file1.isFile()){ results.add(file1.getAbsolutePath()); } else if (file1.isDirectory()){ File file2 = new File(file1.getAbsolutePath()); for (File item : file2.listFiles() ) { results.add(item.getAbsolutePath()); } } } } return results; } public static void main(String[] args) {