Title here
Summary here
A line filter is a common type of program that reads input on stdin, processes it, and then prints some derived result to stdout. grep
and sed
are common line filters.
Here’s an example line filter in Kotlin that writes a capitalized version of all input text. You can use this pattern to write your own Kotlin line filters.
To try out our line filter, first make a file with a few lowercase lines.
Then use the line filter to get uppercase lines.
In this Kotlin version:
BufferedReader
wrapped around System.in
to read input lines.readLine()
method is used to read each line of input.null
is returned (indicating end of input).uppercase()
method is used to convert each line to uppercase.println()
to write the uppercase line to stdout.This Kotlin code achieves the same functionality as the original example, reading lines from standard input, converting them to uppercase, and printing the result to standard output.