Permalink
Browse files

Merge remote-tracking branch 'eengbrec/serializer_fix'

  • Loading branch information...
2 parents f17cfc0 + 753ccff commit b56ce1e4b06b81ec023a393f8a510d2f2f61b003 @djspiewak committed Oct 1, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/main/scala/com/codecommit/antixml/XMLSerializer.scala
@@ -63,11 +63,18 @@ class XMLSerializer(encoding: String, outputDeclaration: Boolean) {
* Uses the character encoding of this XMLSerializer (default is UTF-8).
*/
def serializeDocument(elem: Elem, o: OutputStream) {
- serializeDocument(elem, new OutputStreamWriter(o, encoding))
+ val writer = new OutputStreamWriter(o, encoding)
+ serializeDocument(elem, writer)
+ writer.flush()
}
def serializeDocument(elem: Elem, outputFile: File) {
- serializeDocument(elem, new FileOutputStream(outputFile))
+ val fos = new FileOutputStream(outputFile)
+ try {
+ serializeDocument(elem, fos)
+ } finally {
+ fos.close()
+ }
}
def serialize(elem: Elem, w: Writer) {

0 comments on commit b56ce1e

Please sign in to comment.