Package io.github.dornol.excelkit.csv
Class CsvHandler
java.lang.Object
io.github.dornol.excelkit.core.TempResourceContainer
io.github.dornol.excelkit.csv.CsvHandler
- All Implemented Interfaces:
FileHandler,AutoCloseable
Handles the output stage of a CSV export.
This class holds a temporary CSV file and writes its content to a provided OutputStream.
It ensures the file is only consumed once, and automatically cleans up temporary files afterward.
- Since:
- 2025-07-19
-
Method Summary
Modifier and TypeMethodDescriptionvoidwriteTo(OutputStream outputStream) Writes the content of the CSV file to the given OutputStream.Methods inherited from class io.github.dornol.excelkit.core.TempResourceContainer
close, getTempDir, getTempFile, setTempDir, setTempFileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.dornol.excelkit.core.FileHandler
writeTo
-
Method Details
-
writeTo
Writes the content of the CSV file to the given OutputStream.This method can be called only once. Subsequent calls will throw
CsvWriteException.The temporary file and directory will be deleted automatically after writing.
Note: I/O errors are wrapped as
CsvWriteException(unchecked) rather than propagated asIOException, so callers do not need a try-catch for checked exceptions.- Specified by:
writeToin interfaceFileHandler- Parameters:
outputStream- The stream to which the CSV content will be written- Throws:
CsvWriteException- If this method has already been called or if an I/O error occurs
-