directorystream

List directory content with Project Reactor and DirectoryStream

五迷三道 提交于 2020-05-09 14:11:10
问题 I'd like to use DirectoryStream with Project Reactor to list all the files in a directory. My try is: Path myDir = Paths.get("C:\\Users\\r.dacanal\\Documents\\Reply\\EDA\\logging-consumer\\input"); DirectoryStream<Path> directoryStream = Files.newDirectoryStream(myDir); Flux.fromIterable(directoryStream).doOnNext(s -> System.out.println(s)).subscribe(); But I'm getting the following Exception: Caused by: java.lang.IllegalStateException: Iterator already obtained at sun.nio.fs

Recursively list all files within a directory using nio.file.DirectoryStream;

柔情痞子 提交于 2019-11-26 14:40:02
I want to list all the FILES within the specified directory and subdirectories within that directory. No directories should be listed. My current code is below. It does not work properly as it only lists the files and directories within the specified directory. How can I fix this? final List<Path> files = new ArrayList<>(); Path path = Paths.get("C:\\Users\\Danny\\Documents\\workspace\\Test\\bin\\SomeFiles"); try { DirectoryStream<Path> stream; stream = Files.newDirectoryStream(path); for (Path entry : stream) { files.add(entry); } stream.close(); } catch (IOException e) { e.printStackTrace();

Recursively list all files within a directory using nio.file.DirectoryStream;

时间秒杀一切 提交于 2019-11-26 03:58:49
问题 I want to list all the FILES within the specified directory and subdirectories within that directory. No directories should be listed. My current code is below. It does not work properly as it only lists the files and directories within the specified directory. How can I fix this? final List<Path> files = new ArrayList<>(); Path path = Paths.get(\"C:\\\\Users\\\\Danny\\\\Documents\\\\workspace\\\\Test\\\\bin\\\\SomeFiles\"); try { DirectoryStream<Path> stream; stream = Files