Помогите пожалуйста, пишет таймаут, не пойму что не так)
package com.javarush.task.task31.task3102;
import java.io.File;
import java.io.IOException;
import java.util.*;
/*
Находим все файлы
*/
public class Solution {
public static List<String> getFileTree(String root) throws IOException, InterruptedException {
File file = new File(root);
List<String> filePath = new ArrayList<>();
File fileAll;
Queue<File> queue = new LinkedList<>();
queue.add(file);
while (queue.peek() != null){
fileAll = queue.element().getParentFile();
for (File f : fileAll.listFiles())
{
if(f.isDirectory()){
queue.add(f);
}
else {
filePath.add(f.getAbsolutePath());
}
}
queue.remove();
}
return filePath;
}
public static void main(String[] args) {
List<String> list = null;
try {
list = getFileTree("dir");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
for (String s : list) {
System.out.println(s);
}
}
}