Is there a nice, safe, quick way to write an InputStream to a File in Scala?

pr1001 picture pr1001 · May 6, 2010 · Viewed 15.1k times · Source

Specifically, I'm saving a file upload to local file in a Lift web app.

Answer

notan3xit picture notan3xit · Feb 21, 2013

With Java 7 or later you can use Files from the new File I/O:

Files.copy(from, to)

where from and to can be Paths or InputStreams. This way, you can even use it to conveniently extract resources from applications packed in a jar.