I am facing a rather unusual situation. I am using printWriter
with System.out
to print the bytes from a file onto console, first using a ByteStr
I can see 2 significant problems with your FileStream
and CharacterStream
classes.
Both classes call close()
on the PrintWriter
that wraps System.out
. When that happens System.out
will be closed, and no further writes to it will be permitted.
Both classes squash IO exceptions. That is they catch the exception, say nothing, and continue as if nothing happened. That is extremely poor coding practice ... and it is most likely hiding the exceptions that happen when you write to the closed System.out
stream.
There are also a variety of style problems, the worst of which is your poor choice of method and class names. For example the printOnConsole methods don't print on the console. Rather they print on the standard output stream ... which may go to somewhere other than the console. (And your application can't tell!!)