Не понимаю почему метод 'isRegularFile' не работает. Писал по статье, но почему то не работает(
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Solution {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Path path = Paths.get(reader.readLine());

    }

    public static List<Path> whatInnerFile(Path path) throws IOException {
        if (!Files.isDirectory(path)){
            System.out.println(path + "- не папка");
            return null;
        }
        List<Path> result;
        try (Stream stream = Files.walk(path)) {
            result = stream.filter(Files::isRegularFile)
                    .collect(Collectors.toList());
        }
        return result;
    }
}