public void execute() { try { // Only execute the reports for the profiler if the snapshot interval is set long snapshptInterval = Configuration.getConfiguration().getSnapshotInterval(); logger.error("Reporter : "); if (snapshptInterval < 0) { return; } try { // Write the style sheet first File file = new File("./" + IConstants.STYLE_SHEET_FILE); if (!file.exists()) { InputStream inputStream = Reporter.class.getResourceAsStream(IConstants.REPORT_STYLE_SHEET); Toolkit.setContents(file, Toolkit.getContents(inputStream).toByteArray()); } } catch (Exception e) { logger.error("Exception writing the style sheet : ", e); } String html = methodSeries(dataBase); writeReport(IConstants.METHOD_SERIES_FILE, html); } catch (Exception e) { logger.error("Exception writing the reports", e); } super.execute(); }
/** * Writes the report data to the file system. * * @param name the name of the report * @param html the html to write in the file */ private void writeReport(String name, String html) { try { File file = new File(name); if (!file.getParentFile().exists()) { //noinspection ResultOfMethodCallIgnored file.getParentFile().mkdirs(); } if (!file.exists()) { //noinspection ResultOfMethodCallIgnored file.createNewFile(); } logger.error("Writing report : " + file.getAbsolutePath()); Toolkit.setContents(file, html.getBytes(IConstants.ENCODING)); } catch (Exception e) { logger.error("Exception writing report : " + name, e); } }