Writers
![Javadocs](https://camo.githubusercontent.com/56b958cfe247c28c834e0be37481e12671cb1d5f711afc4ed780cb8618124216/68747470733a2f2f7777772e6a617661646f632e696f2f62616467652f636f6d2e6769746875622e6d6172736368616c6c2f777269746572732e737667)
Implementations of java.io.Writer
with different trade-offs.
java.io.OutputStreamWriter
is very flexible and supports any encoding. However its use of sun.nio.cs.StreamEncoder
can result in a noticeable overhead for small writes. It allocates a few temporary objects which for small writes can be noticeable. By addressing only special cases we can make optimizations based on different trade-offs.
Currently we only offer the following two classes:
com.github.marschall.writers.AsciiOutputStreamWriter
, only supports US-ASCII.- does not allocate any objects
- thread-safe
com.github.marschall.writers.BufferedAsciiOutputStreamWriter
, only supports US-ASCII but also buffers like ajava.io.BufferedOutputStream
. This can result in more efficient writes than usingcom.github.marschall.writers.AsciiOutputStreamWriter
withjava.io.BufferedOutputStream
.- does not allocate any objects beyond the initial
byte[]
, the#write
and#append
methods do not allocate memory - uses bulk array copy methods on Java 9+
- not thread-safe
- does not allocate any objects beyond the initial
This project requires Java 11.