resolved null pointer exception

Former-commit-id: 3cc97c878a2bcc09c8a2cea3802278974d56b954
This commit is contained in:
Jeremy Long
2014-12-08 05:41:58 -05:00
parent 3e6787fd61
commit 589c761cb0

View File

@@ -291,17 +291,20 @@ public class ReportGenerator {
* @throws Exception is thrown when an exception occurs.
*/
protected void generateReport(String templateName, String outFileName) throws Exception {
final File outDir = new File(outFileName).getParentFile();
if (!outDir.exists()) {
final boolean created = outDir.mkdirs();
File outFile = new File(outFileName);
if (outFile.getParentFile() == null) {
outFile = new File(".", outFileName);
}
if (!outFile.getParentFile().exists()) {
final boolean created = outFile.getParentFile().mkdirs();
if (!created) {
throw new Exception("Unable to create directory '" + outDir.getAbsolutePath() + "'.");
throw new Exception("Unable to create directory '" + outFile.getParentFile().getAbsolutePath() + "'.");
}
}
OutputStream outputSteam = null;
try {
outputSteam = new FileOutputStream(outFileName);
outputSteam = new FileOutputStream(outFile);
generateReport(templateName, outputSteam);
} finally {
if (outputSteam != null) {