pickling
pickling copied to clipboard
TextFileOutput improvements
This is a feature proposal
Currently we have TextFileOutput but it has some potential issues.
- PrintWriter eats exceptions ("never throw I/O exceptions") so it's probably not recommended for anything other than hello world.
- It's relying on JVM default charset instead of specifying UTF-8.
- Not buffered.
A quick change would be to make something that just does the above, which is what I added for sbt/serialization#8, but I think we could do better. The problem with buffering is that it needs to be closed afterwards.
Here are some improvement ideas:
-
BufferedWriterOutput
— a generalOutput[String]
forjava.io.BufferedWriter
-
BufferedWriterOutput.apply
function forFile
that createsjava.io.BufferedWriter
with UTF-8 hardcoding -
pickleTo
function callsclose
on the builder it creates (otherwise buffered output would be half hanging)