Package org.sosy_lab.common.io
Class TempFile
- java.lang.Object
-
- org.sosy_lab.common.io.TempFile
-
public final class TempFile extends Object
Utilities for temporary files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TempFile.DeleteOnCloseDir
A simple wrapper aroundPath
that callsMoreFiles.deleteRecursively(Path, com.google.common.io.RecursiveDeleteOption...)
recursively fromAutoCloseable.close()
to delete the directory including its contents.static class
TempFile.DeleteOnCloseFile
static class
TempFile.TempFileBuilder
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TempFile.TempFileBuilder
builder()
Create a builder for temporary files.static TempFile.DeleteOnCloseDir
createDeleteOnCloseDir(String pPrefix, FileAttribute<?>... pFileAttributes)
Create a fresh temporary directory in JVM's temp directory.
-
-
-
Method Detail
-
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 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
- TheFileAttribute
s used for creating the directory.- Throws:
IOException
-
-