private static PrintWriter openBodyFile(Body b, String baseName) throws java.io.IOException { File dir = makeDirectoryIfMissing(b); String filePath = dir.toString() + File.separatorChar + baseName; return new PrintWriter(new java.io.FileOutputStream(filePath)); }
/** * Returns the next available name for a graph file. */ private static String nextGraphFileName(Body b, String baseName) throws java.io.IOException { // We number output files to allow multiple graphs per phase. File dir = makeDirectoryIfMissing(b); final String prefix = dir.toString() + File.separatorChar + baseName; File file = null; int fileNumber = 0; do { file = new File(prefix + fileNumber + DotGraph.DOT_EXTENSION); fileNumber++; } while (file.exists()); return file.toString(); }
private static void deleteOldGraphFiles(final Body b, final String phaseName) { try { final File dir = makeDirectoryIfMissing(b); final File[] toDelete = dir.listFiles(new java.io.FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith(phaseName) && name.endsWith(DotGraph.DOT_EXTENSION); } }); if (toDelete != null) { for (File element : toDelete) { element.delete(); } } } catch (java.io.IOException e) { // Don't abort execution because of an I/O error, but report // the error. logger.debug("PhaseDumper.dumpBody() caught: " + e.toString()); logger.error(e.getMessage(), e); } }