- java.lang.Object
-
- com.gluonhq.connect.source.FileDataSource
-
- All Implemented Interfaces:
InputDataSource
,IODataSource
,OutputDataSource
public class FileDataSource extends Object implements IODataSource
An implementation ofIODataSource
that can read from and write to a file.Attention: it is advised not to use this class directly, but rather construct it by creating a
FileClient
and build the FileDataSource with theFileClient.createFileDataSource()
method.
-
-
Constructor Summary
Constructors Constructor Description FileDataSource(File file)
Create a new FileDataSource instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description File
getFile()
Returns the file that this data source is mapped to.InputStream
getInputStream()
Returns an InputStream that is able to read data from the file that was passed in when constructing the FileDataSource.OutputStream
getOutputStream()
Returns an OutputStream that is able to write data to the file that was passed in when constructing the FileDataSource.
-
-
-
Constructor Detail
-
FileDataSource
public FileDataSource(File file)
Create a new FileDataSource instance. The provided file will be used for reading from and/or storing data into.- Parameters:
file
- the file to use for reading the data from from or writing the data to
-
-
Method Detail
-
getFile
public File getFile()
Returns the file that this data source is mapped to.- Returns:
- the file that this data source will use for reading and writing data
-
getInputStream
public InputStream getInputStream() throws IOException
Returns an InputStream that is able to read data from the file that was passed in when constructing the FileDataSource.- Specified by:
getInputStream
in interfaceInputDataSource
- Returns:
- an InputStream that is able to read from the file
- Throws:
IOException
- when the InputStream on the file could not be created
-
getOutputStream
public OutputStream getOutputStream() throws IOException
Returns an OutputStream that is able to write data to the file that was passed in when constructing the FileDataSource.- Specified by:
getOutputStream
in interfaceOutputDataSource
- Returns:
- an OutputStream that is able to write to the file
- Throws:
IOException
- when the OutputStream on the file could not be created
-
-