var filename = \"blesson.txt\" var wallpaperDirectory = File(\"/sdcard/Wallpaper\") wallpaperDirectory.mkdirs() val outputFile = File(wallpaperDirectory, filename) val
You can also use also to do this:
also
File("path_to_file").also { file -> file.parentFile.mkdirs() }.writeBytes(bytes)