1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package net.sourceforge.pmd.cpd;
5
6 import java.io.BufferedWriter;
7 import java.io.File;
8 import java.io.FileWriter;
9 import java.io.IOException;
10 import java.io.Writer;
11
12 /***
13 * @author Philippe T'Seyen
14 */
15 public class FileReporter
16 {
17 private File reportFile;
18
19 public FileReporter(File reportFile) {
20 if (reportFile == null) throw new NullPointerException("reportFile can not be null");
21 this.reportFile = reportFile;
22 }
23
24 public void report(String content) throws ReportException {
25 try {
26 Writer writer = null;
27 try {
28 writer = new BufferedWriter(new FileWriter(reportFile));
29 writer.write(content);
30 } finally {
31 if (writer != null) writer.close();
32 }
33 } catch (IOException ioe) {
34 throw new ReportException(ioe);
35 }
36 }
37 }