Unix/ls: Difference between revisions

270 bytes removed ,  4 years ago
(Added Pike implementation)
Line 532:
 
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
Line 541 ⟶ 539:
 
public static void main(String[] args) throws IOException {
Files.list(Path.of(".")).forEach(System.out::println);
UnixLS ls = new UnixLS();
ls.list(System.out);
}
 
private void list(PrintStream out) throws IOException {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("."))) {
stream.forEach((path) -> out.println(path.getFileName()));
}
}
}
 
</lang>
 
Anonymous user