Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steklopod/e410d0efbedbfb5b8aeba28111123c55 to your computer and use it in GitHub Desktop.
Save steklopod/e410d0efbedbfb5b8aeba28111123c55 to your computer and use it in GitHub Desktop.
package com.javarush.task.task31.task3102;
import java.io.File;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
/*
Находим все файлы
*/
public class Solution {
public static List<String> getFileTree(String root) throws IOException {
File rootDir = new File(root);
ArrayList<String> list = new ArrayList<>();
Queue<File> fileTree = new PriorityQueue<>();
Collections.addAll(fileTree, rootDir.listFiles());
while (!fileTree.isEmpty())
{
File currentFile = fileTree.remove();
if(currentFile.isDirectory()){
Collections.addAll(fileTree, currentFile.listFiles());
} else {
list.add(currentFile.getAbsolutePath());
}
}
return list;
}
public static void main(String[] args) {
}
}
@qoxxop
Copy link

qoxxop commented Sep 23, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment