Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,14 +1,18 @@
import java.io.File
import java.io.{File, FileWriter, IOException}
try {
// Create temp file
val filename = File.createTempFile("prefix", ".suffix")
def writeStringToFile(file: File, data: String, appending: Boolean = false) =
using(new FileWriter(file, appending))(_.write(data))
// Delete temp file when program exits
filename.deleteOnExit
def using[A <: {def close() : Unit}, B](resource: A)(f: A => B): B =
try f(resource) finally resource.close()
System.out.println(filename)
} catch {
case _: java.io.IOException =>
}
try {
val file = File.createTempFile("_rosetta", ".passwd")
// Just an example how you can fill a file
using(new FileWriter(file))(writer => rawDataIter.foreach(line => writer.write(line)))
scala.compat.Platform.collectGarbage() // JVM Windows related bug workaround JDK-4715154
file.deleteOnExit()
println(file)
} catch {
case e: IOException => println(s"Running Example failed: ${e.getMessage}")
}