Writer or OutputStream?
java
Solution
An `OutputStream` is a byte-oriented stream. Any text you write has to be encoded as bytes using some encoding (most commonly ISO-8859-1 or UTF-8). A `Writer` is a character-oriented stream that may or may not internally encode characters as bytes, depending on what it is writing to.
EDIT If you are designing a library, then if you provide an `OutputStream`-oriented interface to which text is to be written, you really should provide client classes the ability to control the encoding to be used.
Problem
I'm designing a library where a class should have an ability to be able to convert itself internals into text. Which class shall I use: `OutputStream` or `Writer`? And what is the key difference between them (in my case)? ``` public interface Memento { void save(OutputStream stream); void save(Writer writer); } ``` Which one?