https://github.com/marschall/writers
implementations of java.io.Writer with different trade-offs
https://github.com/marschall/writers
character-encoding input-output java
Last synced: 3 months ago
JSON representation
implementations of java.io.Writer with different trade-offs
- Host: GitHub
- URL: https://github.com/marschall/writers
- Owner: marschall
- Created: 2019-09-18T10:28:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-03T18:35:09.000Z (over 4 years ago)
- Last Synced: 2025-01-16T02:44:54.308Z (4 months ago)
- Topics: character-encoding, input-output, java
- Language: Java
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Writers [](https://maven-badges.herokuapp.com/maven-central/com.github.marschall/writers) [](https://www.javadoc.io/doc/com.github.marschall/writers)
=======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](https://en.wikipedia.org/wiki/ASCII).
* does not allocate any objects
* thread-safe
* `com.github.marschall.writers.BufferedAsciiOutputStreamWriter`, only supports [US-ASCII](https://en.wikipedia.org/wiki/ASCII) but also buffers like a `java.io.BufferedOutputStream`. This can result in more efficient writes than using `com.github.marschall.writers.AsciiOutputStreamWriter` with `java.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-safeThis project requires Java 11.