package com.utility.generator.file;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import com.utility.generator.exception.FixtureGeneratorException;

public class FileBuilder {

	public void createFile(String className, String path, String content) {
		try {
			File file = new File(path + "/" + className + ".java");
			file.getParentFile().mkdirs();
			FileWriter fw = new FileWriter(file.getAbsoluteFile());
			BufferedWriter bw = new BufferedWriter(fw);
			bw.write(content);
			bw.close();
		} catch (IOException e) {
			throw new FixtureGeneratorException("An error occurred while generating the file: " + e.getMessage());
		}
	}

}

@@ -310,17 +310,8 @@
 ) %7B%0A
-%09%09try %7B%0A%09
 %09%09Fi
@@ -366,17 +366,16 @@
 va%22);%0A%09%09
-%09
 file.get
@@ -403,29 +403,40 @@
 ;%0A%09%09
-%09File
+%0A%09%09try (Buffered
 Writer 
-f
+b
 w = new 
 File
@@ -427,24 +427,43 @@
 er bw = new 
+BufferedWriter(new 
 FileWriter(f
@@ -488,56 +488,11 @@
 e())
-;%0A%09%09%09BufferedWriter bw = new BufferedWriter(fw);
+))%7B
 %0A%09%09%09
@@ -514,23 +514,8 @@
 t);%0A
-%09%09%09bw.close();%0A
 %09%09%7D 

Resolve Sonar issue