KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > cpd > FileReporter


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 JavaDoc;
7 import java.io.File JavaDoc;
8 import java.io.FileWriter JavaDoc;
9 import java.io.IOException JavaDoc;
10 import java.io.Writer JavaDoc;
11
12 /**
13  * @author Philippe T'Seyen
14  */

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