List of utility methods to do Temp Directory Create
File | createTempDirectory(String prefix) Create a uniquely-named temporary directory. File baseDir = new File(System.getProperty("java.io.tmpdir")); baseDir.mkdirs(); while (true) { File tempDir = new File(baseDir, prefix + Math.abs(random.nextLong())); if (!tempDir.exists()) { if (tempDir.mkdir()) { return tempDir; |
File | createTempDirectory(String prefix) Creates a temporary directory whose name starts with the given prefix . File tempDir = Files.createTempDirectory(prefix).toFile();
tempDir.deleteOnExit();
return tempDir;
|
File | makeTempDir() make Temp Dir File tmpFile = File.createTempFile("temp-dir", "tmp"); tmpFile.deleteOnExit(); String filename = tmpFile.getCanonicalPath(); String dirname = filename.substring(0, filename.length() - 4); File tmpDir = new File(dirname); if (!tmpDir.mkdir()) { throw new IOException("Can't create temp directory: " + dirname); return tmpDir; |
File | makeTempDir(String name) make Temp Dir File tempDir = new File(tmpDirName); if (!tempDir.isDirectory()) { throw new RuntimeException("Temp dir " + tmpDirName + " does not exist"); File subDir = new File(tempDir, name); if (!subDir.exists()) { subDir.mkdir(); return subDir; |
File | makeTempDir(String prefix) make Temp Dir File temp; do { temp = new File(System.getProperty("java.io.tmpdir"), prefix + '-' + UUID.randomUUID()); } while (temp.exists()); if (!temp.mkdir()) { throw new IOException("Couldn't create temp directory: " + temp); cTempFiles.add(temp); ... |
File | makeTempDir(String prefix) make Temp Dir if (null == prefix) { prefix = "tempDir"; File tempFile = null; for (int i = 0; i < 10; i++) { try { tempFile = File.createTempFile(prefix, "tmp"); tempFile.delete(); ... |
File | makeTempDir(String prefix, String suffix) make Temp Dir final File instrDir = File.createTempFile(prefix, suffix); instrDir.delete(); instrDir.mkdir(); return instrDir; |
File | makeTempDirectory(String dirName, boolean deleteIfExists) make Temp Directory return makeTempDirectory(null, dirName, deleteIfExists);
|
File | makeTempDirectory(String prefix, String suffix) Creates an empty directory in the default temporary-file directory, using the given prefix and suffix to generate its name. File dir = File.createTempFile(prefix, suffix); if (!dir.delete()) throw new IOException("could not delete temporary file: " + dir); if (!dir.mkdir()) throw new IOException("could not make temporary directory: " + dir); return dir; |
File | makeTemporaryDirectory() make Temporary Directory return makeTemporaryDirectory("kiradb", ".index"); |