Java
Summary
This page contains links to most Java topics. Java, created by James Gosling, among others.
Tools
- Java build systems
- Includes Maven
- JReleaser
- JUnit
Concepts
Reference
Get user home directory
System.getProperty("user.home");
List files recursively
try (Stream<Path> walk = Files.walk(Paths.get(input))) {
List<String> result =
.filter(Files::isRegularFile)
walk.map(x ->x.toString())
.collect(Collectors.toList());
.forEach(System.out::println);
result} catch (IOException e) {
.printStackTrace();
e}
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());
Setting the logger level
From the CLI specify it with, for instance to set the logger level to info
:
$ mvn test -Dorg.slf4j.simpleLogger.defaultLogLevel=info