I have the some code:
directoryChooser.title = \"Select the directory\"
val file = directoryChooser.showDialog(null)
if (file != null) {
var files = File
This is another work around if you are for some reason stuck on older beta version of Kotlin which requires a more brutal workaround...
Workaround #3: (ugly, an old workaround ONLY for old versions of Kotlin)
Add this Java class to your project:
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class CollectFix {
public static List streamToList(Stream s) {
return s.collect(Collectors.toList());
}
}
And this one Kotlin extension function:
fun Stream.toList(): List = CollectFix.streamToList(this)
And then any time you have this case, use this new extension:
Files.list(Paths.get(file)).filter { /* filter clause */ }.toList()