- import java.io.File
-
- fun main(args: Array<String>) {
- val filePath = "."
-
- val file = File(filePath)
- val fileTree: FileTreeWalk = file.walk()
-
- fileTree
- //.maxDepth(1) //遍历层级1,不检查子目录
- .filter {
- it.isFile //只选文件,不处理文件夹
- }.forEach {
- //println(it.path)
- }
-
- file.list().forEach {
- println(it)
- }
- }