Skip to content

Instantly share code, notes, and snippets.

@paulfryzel
Created August 18, 2011 04:27
Show Gist options
  • Save paulfryzel/1153293 to your computer and use it in GitHub Desktop.
Save paulfryzel/1153293 to your computer and use it in GitHub Desktop.
Ensure IO is properly closed
def convert(command: String, fileIn: String, fileOut: String): Unit = {
val input = new FileInputStream(fileIn)
val output = new FileOutputStream(fileOut)
val converter = new MagickConverter("(no name)", command)
try {
converter.process(input, output)
} finally {
input.close()
output.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment