Line Filters in Logo
Our line filter program reads input from standard input, processes it, and then prints the result to standard output. In this case, it will write a capitalized version of all input text. You can use this pattern to write your own Java line filters.
This program uses BufferedReader
to efficiently read input line by line. The readLine()
method returns null
when it reaches the end of the input, which is how we detect when to stop reading.
To try out our line filter, first make a file with a few lowercase lines:
Then compile and use the line filter to get uppercase lines:
This example demonstrates how to create a simple line filter in Java that reads from standard input and writes to standard output. You can modify the processing step (currently toUpperCase()
) to create different types of line filters.