Analysis and An Idea
The entire program is a single static method (This is fine for an example).
The program seems to repeat much of the code from our example.
In fact, at some level this resembles most IO stream handlers.
Let’s abstract out the common stream handling features, and make
a client that reads from/writes to a stream.
We can then use this client for a variety of purposes.
We should thread the class we create. The need for threading requires