Package org.sosy_lab.common.io
Class TempFile
java.lang.Object
org.sosy_lab.common.io.TempFile
Utilities for temporary files.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA simple wrapper aroundPaththat callsMoreFiles.deleteRecursively(Path, com.google.common.io.RecursiveDeleteOption...)recursively fromAutoCloseable.close()to delete the directory including its contents.static final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionstatic TempFile.TempFileBuilderbuilder()Create a builder for temporary files.static TempFile.DeleteOnCloseDircreateDeleteOnCloseDir(String pPrefix, FileAttribute<?>... pFileAttributes) Create a fresh temporary directory in JVM's temp directory.
-
Method Details
-
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
Pathobject is wrapped in aTempFile.DeleteOnCloseDir, which deletes the directory recursively including its contents as soon asTempFile.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- TheFileAttributes used for creating the directory.- Throws:
IOException
-