CodeWriter

April 5: The CodeWriter class has been updated with a new version that generates the optimum format.

The CodeWriter class provides essential support for pretty-printing: automatically formatting structured text. When a CodeWriter object is created, two parameters have to be specified: an OutputStream object o and an integer width. The CodeWriter will format text onto o while keeping the width of the output within width characters if possible.

It can be a little tricky to get the expected output when you first use CodeWriter. But after some experiments, you will find it is a nice tool. Here are some tips that might shorten your learning time.