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 private File reportFile;
17
18 public FileReporter(File reportFile) {
19 if (reportFile == null) throw new NullPointerException("reportFile can not be null");
20 this.reportFile = reportFile;
21 }
22
23 public void report(String content) throws ReportException {
24 try {
25 Writer writer = null;
26 try {
27 writer = new BufferedWriter(new FileWriter(reportFile));
28 writer.write(content);
29 } finally {
30 if (writer != null) writer.close();
31 }
32 } catch (IOException ioe) {
33 throw new ReportException(ioe);
34 }
35 }
36 }