Package org.pgcodekeeper.core.utils
Class TempDir
java.lang.Object
org.pgcodekeeper.core.utils.TempDir
- All Implemented Interfaces:
AutoCloseable
Wrapper for creation and automatic recursive deletion of a temporary directory.
Intended for try-with-resources usage to ensure proper cleanup.
Automatically deletes the directory and all its contents when closed.
- Author:
- Alexander Levsha
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TempDir
Creates a temporary directory with specified prefix in the system temp directory.- Parameters:
prefix- the directory name prefix- Throws:
IOException- if directory creation fails
-
TempDir
Creates a temporary directory with specified prefix in the given parent directory.- Parameters:
dir- the parent directoryprefix- the directory name prefix- Throws:
IOException- if directory creation fails
-
-
Method Details
-
get
Returns the path to the temporary directory.- Returns:
- path to the temporary directory
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-