java.lang.Object
net.luis.utils.io.data.InputProvider
- All Implemented Interfaces:
AutoCloseable
Input provider for reading data from a file or stream.
This class provides several constructors for different input sources.
This class provides several constructors for different input sources.
Primary usage of this class is to provide an input stream for different input sources.
This can be useful for other readers or parsers to keep their constructors clean and simple.
AutoCloseable
, so it can be used in try-with-resources statements.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInputProvider
(@NotNull File file) Constructs a new input provider for the given file.InputProvider
(@NotNull InputStream stream) Constructs a new input provider for the given input stream.InputProvider
(@NotNull String file) Constructs a new input provider for the given file.InputProvider
(@NotNull String path, @NotNull String fileName) Constructs a new input provider for the given path and file name.
The path and file name are concatenated to a file.InputProvider
(@NotNull Path path) Constructs a new input provider for the given path.InputProvider
(@NotNull ResourceLocation location) Constructs a new input provider for the given resource location. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
@NotNull InputStream
Returns the internal input stream for reading data.
The input stream should not be used directly, it is intended to be passed to other readers or parsers.
-
Field Details
-
stream
The input stream for reading data.
-
-
Constructor Details
-
InputProvider
Constructs a new input provider for the given file.- Parameters:
file
- The file to read data from- Throws:
NullPointerException
- If the file is nullUncheckedIOException
- If the file is not found
-
InputProvider
Constructs a new input 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
-
InputProvider
Constructs a new input 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
-
InputProvider
Constructs a new input provider for the given file.- Parameters:
file
- The file to read data from- Throws:
NullPointerException
- If the file is nullUncheckedIOException
- If the file is not found
-
InputProvider
Constructs a new input provider for the given resource location.- Parameters:
location
- The resource location to read data from- Throws:
NullPointerException
- If the resource location is nullUncheckedIOException
- If the resource could not be opened
-
InputProvider
Constructs a new input provider for the given input stream.- Parameters:
stream
- The input stream to read data from- Throws:
NullPointerException
- If the input stream is null
-
-
Method Details
-
getStream
Returns the internal input stream for reading data.
The input stream should not be used directly, it is intended to be passed to other readers or parsers.- Returns:
- The input stream
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-