/** * Create directory that is automatically cleaned up after the * JVM shuts down through use of a Runtime shutdown hook. * * @param dir Directory to create, including missing parent directories * @return File handle to the created temp directory */ public static File createTempDir(File dir) throws IOException { return createTempDir(dir, true); }
public static void verboseLogging() { verboseLogging("%d [%p|%c|%C{1}] %m%n", Level.ALL); }
@BeforeClass public static void setUp() throws Exception { tmpDir = UnitTestHelper.createTempDir(new File("target/jsonutilstest")); configFile = UnitTestHelper.write(new File(tmpDir, "config.json"), config); }
/** * Create directory that is optionally cleaned up after the * JVM shuts down through use of a Runtime shutdown hook. * * @param prefix Prefix to apply to temp directory name * @param cleanup true/false * @return File handle to the created temp directory * @throws IOException Unable to create temp directory */ public static File createTempDir(String prefix, boolean cleanup) throws IOException { Path tmpDir = Files.createTempDirectory(prefix); addCleanupHook(tmpDir); return tmpDir.toFile(); }
public static String findDir(String name) { return findDir(new File("."), name); }
@Override public void run() { try { cleanDir(dir); } catch (IOException e) { System.out.println(format("Warning: Unable to clean folder '%s'", dir.toString())); } } });
/** * Create directory that is automatically cleaned up after the * JVM shuts down through use of a Runtime shutdown hook. * * @param dir Directory to create, including missing parent directories * @param cleanup true/false * @return File handle to the created temp directory */ public static File createTempDir(File dir, boolean cleanup) throws IOException { if (!dir.mkdirs() && !dir.exists()) { throw new IOException(String.format("Failed to create directory structure '%s'", dir.toString())); } if (cleanup) { addCleanupHook(dir.toPath()); } return dir; }
/** * Create directory that is automatically cleaned up after the * JVM shuts down through use of a Runtime shutdown hook. * * @param prefix Prefix to apply to temp directory name * @return File handle to the created temp directory * @throws IOException Unable to create temp directory */ public static File createTempDir(String prefix) throws IOException { return createTempDir(prefix, true); }