I need to retrieve recursively the list of `.java`...
# announcements
e
I need to retrieve recursively the list of
.java
files given a root folder to redirect to
javac
. Isn't there a nicer kotlin alternative to this?
Copy code
val sources = Files.find(Paths.get(srcDir), 999, { path, attr ->
            attr.isRegularFile && path.toString().endsWith(".java")
        }).map { it.toString() }.collect(Collectors.joining(" "))
Files.find
returns a
Stream<Path!>!
and I need to go trough
map
+
collect
+
Collectors
instead something more concise
d
Best I could do.
Copy code
File(srcDir).walk().maxDepth(999)
	.filter { it.isFile && it.extension == "java" }
	.joinToString(" ") { it.toString() }
e
I like it, thanks dear
r
I think
it.toString()
is the default behavior for
joinToString
, so you could just use
.joinToString(" ")
👍 3