I want to create a map for a Path.
That path contains different folders and each folder has some files.
Let's say, path: c:/project
The project has 2 folders A and B. A has 2 text file- 1.txt, 2.txt and B has 3.txt file The output should be [A= {1.txt,2.txt}, B= {3.txt}]
I am using java8 Currently, I am doing
try (Stream<Path> files = Files.list(getOutputDirectory()))
{
Map<String, String> fileList = files.map(input -> input.toFile().getName())
.collect(Collectors.toMap(key -> key, value -> value));
logger.info("testing " + fileList);
}
catch (final IOException exception)
{
exception.printStackTrace();
}
but output is {A=A,B=B}; expected is [A= {1.txt,2.txt}, B= {3.txt}]