Package io.github.dornol.excelkit.core
Class TempResourceContainer
java.lang.Object
io.github.dornol.excelkit.core.TempResourceContainer
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
AbstractReadHandler,CsvHandler
Abstract container class for managing temporary files and directories.
This class is typically used by file-based exporters such as CSV and Excel handlers,
providing automatic cleanup of temporary resources via AutoCloseable.
- Since:
- 2025-07-19
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Attempts to delete the temporary file and directory (if they exist).protected @Nullable PathReturns the path to the temporary directory (if set).protected @Nullable PathReturns the path to the temporary file (if set).protected voidsetTempDir(@Nullable Path tempDir) Sets the path to the temporary directory.protected voidsetTempFile(@Nullable Path tempFile) Sets the path to the temporary file.
-
Constructor Details
-
TempResourceContainer
public TempResourceContainer()Creates a new empty temp resource container.
-
-
Method Details
-
getTempDir
Returns the path to the temporary directory (if set).- Returns:
- the temporary directory path, or null
-
setTempDir
Sets the path to the temporary directory.- Parameters:
tempDir- The directory to store the temporary file
-
getTempFile
Returns the path to the temporary file (if set).- Returns:
- the temporary file path, or null
-
setTempFile
Sets the path to the temporary file.- Parameters:
tempFile- The file that will be eventually streamed
-
close
public void close()Attempts to delete the temporary file and directory (if they exist).Called automatically at the end of file export operations.
- Specified by:
closein interfaceAutoCloseable
-