Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions 08-java-io2/task02/src/com/example/task02/Task02Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;

public class Task02Main {
public static void main(String[] args) throws IOException, InterruptedException {
//здесь вы можете вручную протестировать ваше решение, вызывая реализуемый метод и смотря результат
// например вот так:

/*
System.out.println(listFiles(Paths.get("task02/src/main/resources/")));
*/

public class Task02Main
{
public static void main(String[] args) throws IOException, InterruptedException
{
for (Path path : listFiles(Paths.get("task02/src/main/resources/")))
{
System.out.println(path.getFileName());
}
}

public static List<Path> listFiles(Path rootDir) throws IOException, InterruptedException {
// your implementation here
public static List<Path> listFiles(Path rootDir) throws IOException, InterruptedException
{
List<Path> files = new ArrayList<Path>();

FileVisitor<Path> fileVisitor = new SimpleFileVisitor<Path>()
{
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
{
files.add(file);
return FileVisitResult.CONTINUE;
}
};

return null;
Files.walkFileTree(rootDir, fileVisitor);
return files;
}
}