Last active
September 23, 2020 20:44
-
-
Save steklopod/e410d0efbedbfb5b8aeba28111123c55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!