Package com.palantir.util.file
Class TempFileUtils
- java.lang.Object
-
- com.palantir.util.file.TempFileUtils
-
public final class TempFileUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static File
createTempDirectory(String prefix, String suffix)
static File
createTempFile(String prefix, String suffix)
static File
createTempFile(String prefix, String suffix, File directory)
static void
ensureDirectoryExists(String path)
Ensures that the directory specified by the path existsstatic void
ensureFileExists(File file)
Ensures that the file existsstatic void
ensureTempDirectoryExists()
Ensures that the tmp directory in the java.io.tmpdir system property existsstatic boolean
mkdirsWithRetry(File f)
A thread-safer mkdirs.
-
-
-
Method Detail
-
createTempFile
public static File createTempFile(String prefix, String suffix) throws IOException
- Throws:
IOException
-
createTempFile
public static File createTempFile(String prefix, String suffix, File directory) throws IOException
- Throws:
IOException
-
createTempDirectory
public static File createTempDirectory(String prefix, String suffix) throws IOException
- Throws:
IOException
-
ensureFileExists
public static void ensureFileExists(File file) throws IOException
Ensures that the file exists- Throws:
IOException
-
ensureTempDirectoryExists
public static void ensureTempDirectoryExists() throws IOException
Ensures that the tmp directory in the java.io.tmpdir system property exists- Throws:
IOException
-
ensureDirectoryExists
public static void ensureDirectoryExists(String path) throws IOException
Ensures that the directory specified by the path exists- Throws:
IOException
-
mkdirsWithRetry
public static boolean mkdirsWithRetry(File f)
A thread-safer mkdirs. mkdirs() will fail if another thread creates one of the directories it means to create before it does. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4742723 This attempts the mkdirs() multiple times, so that if another thread does create one of the directories, the next call to mkdirs() will take that into account. Note: this returns true iff the file f ends up being a directory, contrary to mkdirs(), which returns false if it existed before the call.
-
-