Class TempFile

java.lang.Object
org.sosy_lab.common.io.TempFile

public final class TempFile extends Object
Utilities for temporary files.
  • Method Details

    • builder

      public static TempFile.TempFileBuilder builder()
      Create a builder for temporary files.
    • createDeleteOnCloseDir

      public static TempFile.DeleteOnCloseDir createDeleteOnCloseDir(String pPrefix, FileAttribute<?>... pFileAttributes) throws IOException
      Create a fresh temporary directory in JVM's temp directory.

      The resulting Path object is wrapped in a TempFile.DeleteOnCloseDir, which deletes the directory recursively including its contents as soon as TempFile.DeleteOnCloseDir.close() is called.

      It is recommended to use the following pattern: try (DeleteOnCloseDir tempDir = TempFile.createDeleteOnCloseDir()) { // use tempDir.toPath() to get the Path object denoting the temporary directory }

      Parameters:
      pPrefix - The prefix of the randomly-generated directory name.
      pFileAttributes - The FileAttributes used for creating the directory.
      Throws:
      IOException