- java.lang.Object
-
- com.gluonhq.connect.source.FileDataSource
-
- All Implemented Interfaces:
InputDataSource,IODataSource,OutputDataSource
public class FileDataSource extends Object implements IODataSource
An implementation ofIODataSourcethat 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
FileClientand 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 FilegetFile()Returns the file that this data source is mapped to.InputStreamgetInputStream()Returns an InputStream that is able to read data from the file that was passed in when constructing the FileDataSource.OutputStreamgetOutputStream()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:
getInputStreamin 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:
getOutputStreamin interfaceOutputDataSource- Returns:
- an OutputStream that is able to write to the file
- Throws:
IOException- when the OutputStream on the file could not be created
-
-