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