I have stuck with a requirement. I need to list all the files that ends with .txt and some time .srt etc.
I have to show the list of files after scanning through all the directories that are present.
I know how to scan files in a directory.
val dir = File(dirName)
return dir.listFiles(object : FilenameFilter() {
override fun accept(dir: File?, filename: String): Boolean {
return filename.endsWith(".txt")
}
})
But I want to scan all the directories for files that ends with specified extension.
And also I need to edit it. So, Some how I need to get their path.
How can I achieve this in kotlin.