How to use File.walkBottomUp()?


#1

Hi,

I’m trying to make use of File.walkBottomUp(), but IntelliJ IDEA 2017.1 keeps on suggesting me to import java.io.File from Java 8 for it, which does not have walkBottomUp(). Also import kotlin.io.File.walkBottomUp does not work. How am I supposed to use that function?

Thanks in advance!


#2

Ok, so I guess java.io.File is the right import as Kotlin seems to amend the class with walkBottomUp() via an extension function, but for some reason extension functions do not seem to work for me. Any idea why?


#3

What do you mean by “do not seem to work”?


#4

Without knowing what symptoms you’re seeing, a general tip I use is to try your code with http://try.kotlinlang.org - It will help you figure out if the problem is your code or your setup.

… although as soon as I mention this I realize you’re just going to get AccessControlException if you try to do File io in their sandbox.


#5

Sorry for not being more specific. What I meant was that the code does not compile because the symbol is not being found. But I figured it out: I misread the File.walkBottomUp() function to be a static one. Using it like File(dirname).walkBottomUp() works fine now.

Thanks!