About Question enthuware.ocpjp.v21.2.4054 :
Posted: Mon Jan 13, 2025 3:39 am
I am not sure the answer
Code: Select all
09:32:55 m1k0@localhost katalog → tree /tmp/temp
/tmp/temp
├── documents
│ ├── files.txt
│ └── pdfs
│ └── new.pdf
├── face.jpg
└── surnames.txt
3 directories, 4 files
09:36:06 m1k0@localhost katalog → cat /home/m1k0/Projekty/piaskownica/tomee1/sandbox/sandbox/src/main/java/enthuware/ocpjp/v21_2_4054/TestClass.java
package enthuware.ocpjp.v21_2_4054;
import java.io.IOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
public class TestClass {
public static void main(String[] args) {
try (Stream<Path> sp = Files.walk(
// Path.of("c:\\temp"),
Path.of("/tmp/temp"),
2, FileVisitOption.FOLLOW_LINKS)) {
sp
.filter(p -> p.getName(p.getNameCount() - 1).toString().contains(".txt"))
.sorted()
.forEach(System.out::println);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
09:36:30 m1k0@localhost katalog → java /home/m1k0/Projekty/piaskownica/tomee1/sandbox/sandbox/src/main/java/enthuware/ocpjp/v21_2_4054/TestClass.java
/tmp/temp/documents/files.txt
/tmp/temp/surnames.txt