I need to find a file in a directory using Kotlin. Something like:
ls *.bld
If there are a couple results, that's ok. It would be a short list. Now there's thousands of files.
You could create a File object for a directory and then filter on the walk.
val path = File("/path/to/files/directory")
path.walk().filter { it.name.endsWith(".bld") }
PS: walk() returns a Sequence of contents of directory
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With