pickling icon indicating copy to clipboard operation
pickling copied to clipboard

TextFileOutput improvements

Open eed3si9n opened this issue 9 years ago • 0 comments

This is a feature proposal

Currently we have TextFileOutput but it has some potential issues.

  1. PrintWriter eats exceptions ("never throw I/O exceptions") so it's probably not recommended for anything other than hello world.
  2. It's relying on JVM default charset instead of specifying UTF-8.
  3. 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:

  1. BufferedWriterOutput — a general Output[String] for java.io.BufferedWriter
  2. BufferedWriterOutput.apply function for File that creates java.io.BufferedWriter with UTF-8 hardcoding
  3. pickleTo function calls close on the builder it creates (otherwise buffered output would be half hanging)

eed3si9n avatar Mar 06 '15 22:03 eed3si9n