Class TempFileUtils


  • public final class TempFileUtils
    extends Object
    • Method Detail

      • 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.