Suppose I have a java.util.stream.Stream
of objects with some nice toString
method:
What's the shortest/most elegant solution to write this stream to a file, one line per stream element?
For reading, there is the nice Files.lines
method, so I thought there must be a symmetric method for writing to file, but could not find one.
Files.write
only takes an iterable.
FileOutputStream
and then create aPrintStream
? – redxef Aug 17 '15 at 15:36