diff --git a/src/main/java/ca/mcscert/jtet/eventbgenerator/EventBFileWriter.java b/src/main/java/ca/mcscert/jtet/eventbgenerator/EventBFileWriter.java index 04b80dd34bae5e5767bda9c5b746d379be35237d..bf026705112384ec983a62c04451ea70a0eceeba 100644 --- a/src/main/java/ca/mcscert/jtet/eventbgenerator/EventBFileWriter.java +++ b/src/main/java/ca/mcscert/jtet/eventbgenerator/EventBFileWriter.java @@ -28,10 +28,7 @@ */ package ca.mcscert.jtet.eventbgenerator; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; +import java.io.*; /** * @@ -39,14 +36,36 @@ import java.io.OutputStreamWriter; */ final public class EventBFileWriter { - public static void writeEventBFile(String fileName, String fileContent) { + public static void writeEventBBumFile(String fileName, String content) throws IOException { + FileOutputStream fos = null; + try { - BufferedWriter br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName + ".bum"), "UTF8")); - br.write(fileContent); - br.flush(); - br.close(); - } catch (IOException e) { - e.printStackTrace(); + fos = new FileOutputStream(fileName); + OutputStreamWriter osw = null; + + try { + osw = new OutputStreamWriter(fos, "UTF8"); + BufferedWriter bw = null; + + try { + bw = new BufferedWriter(osw); + bw.write(content); + bw.flush(); + } finally { + if (bw != null) { + bw.close(); + } + } + + } finally { + if (osw != null) { + osw.close(); + } + } + } finally { + if (fos != null) { + fos.close(); + } } } }