filereporter.java

来自「检查Java程序漏洞」· Java 代码 · 共 38 行

JAVA
38
字号
/** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html*/package net.sourceforge.pmd.cpd;import java.io.BufferedWriter;import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.Writer;/** * @author  Philippe T'Seyen */public class FileReporter{  private File reportFile;  public FileReporter(File reportFile) {    if (reportFile == null) throw new NullPointerException("reportFile can not be null");    this.reportFile = reportFile;  }  public void report(String content) throws ReportException {    try {      Writer writer = null;      try {        writer = new BufferedWriter(new FileWriter(reportFile));        writer.write(content);      } finally {        if (writer != null) writer.close();      }    } catch (IOException ioe) {      throw new ReportException(ioe);    }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?