We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f7e9090 + 11648ef commit 02f63e5Copy full SHA for 02f63e5
src/main/java/com/mycmd/commands/LsCommand.java
@@ -0,0 +1,14 @@
1
+import java.nio.file.*;
2
+import java.io.IOException;
3
+
4
+public class ListFilesNIO {
5
+ public static void main(String[] args) throws IOException {
6
+ Path dir = Paths.get("."); // Current directory
7
8
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
9
+ for (Path path : stream) {
10
+ System.out.println(Files.isDirectory(path) ? "[DIR] " + path.getFileName() : " " + path.getFileName());
11
+ }
12
13
14
+}
0 commit comments