Say that i have a thing like this
Stream<Path> files = Files.walk(Paths.get(somePath))
That i then stream through and collect
but then i want to convert it to use a SimpleFileVisitor instead because it is needed, how would i do? i have googled and tried for hours without getting anywere. Can you even use Stream with a SimpleFileVisitor? or do i need to redo the method all over? As i understand i need a couple of methods to use SimpleFileVisitor and i feel confused about it. Files.walk were very simple but it doesnt work for my intentions.
SimpleFileVisitor approach:
In order to use SimpleFileVisitor you can use
walkFileTree
in the following way:This lets you to perform actions while visiting each file, but it has nothing to do with streams (well stream is a tool that you should use when it fits your needs, do not force yourself to use it when not convenient)
Stream approach:
If you prefer walk & stream you can do the following:
Not sure why you need SimpleFileVisitor here,as your explanation:
is pretty mysterious ;)