01: package org.acm.seguin.pmd.cpd;
02:
03: import java.io.BufferedWriter;
04: import java.io.File;
05: import java.io.FileWriter;
06: import java.io.IOException;
07: import java.io.Writer;
08:
09: /**
10: * @author Philippe T'Seyen
11: */
12: public class FileReporter {
13: private File reportFile;
14:
15: public FileReporter(File reportFile) {
16: if (reportFile == null)
17: throw new NullPointerException("reportFile can not be null");
18: this .reportFile = reportFile;
19: }
20:
21: public void report(String content) throws ReportException {
22: try {
23: Writer writer = null;
24: try {
25: writer = new BufferedWriter(new FileWriter(reportFile));
26: writer.write(content);
27: } finally {
28: if (writer != null)
29: writer.close();
30: }
31: } catch (IOException ioe) {
32: throw new ReportException(ioe);
33: }
34: }
35: }
|