java.lang.Object
net.luis.utils.io.data.OutputProvider
- All Implemented Interfaces:
AutoCloseable
Output provider for writing data to a file or stream.
This class provides several constructors for different types of output sources.
This class provides several constructors for different types of output sources.
Primary usage of this class is to provide an output stream for different output sources.
This can be useful for other writers or formatters to keep their constructors clean and simple.
AutoCloseable
, so it can be used in try-with-resources statements.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOutputProvider
(@NotNull File file) Constructs a new output provider for the given file.OutputProvider
(@NotNull OutputStream stream) Constructs a new output provider for the given output stream.OutputProvider
(@NotNull String file) Constructs a new output provider for the given file.OutputProvider
(@NotNull String path, @NotNull String fileName) Constructs a new output provider for the given path and file name.
The path and file name are concatenated to a file.OutputProvider
(@NotNull Path path) Constructs a new output provider for the given path. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
@NotNull OutputStream
Returns the internal output stream for writing data.
The output stream should not be used directly, it is intended to be passed to other writers or formatters.
-
Field Details
-
stream
The output stream for writing data.
-
-
Constructor Details
-
OutputProvider
Constructs a new output provider for the given file.- Parameters:
file
- The file to write data to- Throws:
NullPointerException
- If the file is nullUncheckedIOException
- If the file is not found
-
OutputProvider
Constructs a new output provider for the given path and file name.
The path and file name are concatenated to a file.- Parameters:
path
- The path to the filefileName
- The name of the file- Throws:
NullPointerException
- If the path or file name is nullUncheckedIOException
- If the file is not found
-
OutputProvider
Constructs a new output provider for the given path.- Parameters:
path
- The path to the file- Throws:
NullPointerException
- If the path is nullUncheckedIOException
- If the file is not found
-
OutputProvider
Constructs a new output provider for the given file.- Parameters:
file
- The file to write data to- Throws:
NullPointerException
- If the file is nullUncheckedIOException
- If the file is not found
-
OutputProvider
Constructs a new output provider for the given output stream.- Parameters:
stream
- The output stream to write data to- Throws:
NullPointerException
- If the stream is null
-
-
Method Details
-
getStream
Returns the internal output stream for writing data.
The output stream should not be used directly, it is intended to be passed to other writers or formatters.- Returns:
- The output stream
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-