Skip to content

Commit

Permalink
more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyzzz committed Feb 22, 2021
1 parent 9f93548 commit 9268380
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/ReadAllFiles.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ fun main() {

repeat(5) {
val time = measureTimeMillis {
Files.walk(home).parallel()

Files.walk(home)
.parallel()
.filter { Files.isRegularFile(it) }
.filter {
val name = it.fileName.toString()
name.endsWith(".java") ||
name.endsWith(".kt")
}.map {
it to Files.readString(it, StandardCharsets.UTF_8).contains("Swapper32")
}
.collect(Collectors.toList())
.forEach { runCatching { Files.readAllBytes(it) } }
}

println("Java + Kotlin read is completed in: ${time}ms")
println("Java + Kotlin read is completed in: ${time}ms")
}
}
}

private fun String.endsWithAny(vararg suffix: String) = suffix.any { endsWith(it) }

0 comments on commit 9268380

Please sign in to comment.