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