Java

Notes on Java.

Reference

Get user home directory

System.getProperty("user.home");

List files recursively

try (Stream<Path> walk = Files.walk(Paths.get(input))) {  
    List<String> result = 
        walk.filter(Files::isRegularFile)  
        .map(x ->x.toString())
        .collect(Collectors.toList());  
    result.forEach(System.out::println);  

} catch (IOException e) {  
    e.printStackTrace();  
}

In case we want the file subset with a specific extension, txt we can filter the stream with

    List<String> result = walk.filter(Files::isRegularFile)
        .filter(x -> x.toString().endsWith(".txt"))
        .map(x -> x.toString())
        .collect(Collectors.toList());