Guest User

Untitled

a guest
May 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. /**
  2. * Sample code to handle file system
  3. */
  4.  
  5. import java.io.File
  6.  
  7. /**
  8. * Get all sub file objects in the directory.
  9. */
  10. fun sample1(path: String): Array<File> {
  11. val f = File(String)
  12. return f.listFiles()
  13. }
  14.  
  15. /**
  16. * Iterate files in the directory.
  17. */
  18. fun sample2(path: String, block: File.() -> Unit) {
  19. val d = File(path)
  20. for (file in d.listFiles()) {
  21. block()
  22. }
  23. }
Add Comment
Please, Sign In to add comment