An OutputStream
is a stream that can record information. This is quite common, so for special purposes, such as writing to files, there are specialized OutputStream
. A stream can only write arrays of bytes.
Writer
provide more flexibility in that they can write characters and even strings when considering special encoding.
Which one to take is really a question of what you want to write. If you already have bytes, you can use the stream directly. If you have characters or strings, you need to either convert them to bytes yourself if you want to write them to a stream, or you need to use Writer
, which does the job for you.
source share