Class FileRandomIO
java.lang.Object
org.globus.ftp.FileRandomIO
- All Implemented Interfaces:
DataSink, DataSource
Thread safe reference implementation of DataSink and DataSource.
Implements reading and writing data to a local file.
Note: Does not work with
Session.STREAM
transfer mode, only with GridFTPSession.EBLOCK mode.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intstatic final intprotected RandomAccessFileprotected long -
Constructor Summary
ConstructorsConstructorDescriptionFileRandomIO(RandomAccessFile file) Behave like FileRandomIO(file, DEFAULT_BUFFER_SIZE)FileRandomIO(RandomAccessFile file, int bufferSize) -
Method Summary
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
bufferSize
protected int bufferSize -
file
-
offset
protected long offset
-
-
Constructor Details
-
FileRandomIO
Behave like FileRandomIO(file, DEFAULT_BUFFER_SIZE)- Parameters:
file- local file that will be be used as data source or destination
-
FileRandomIO
- Parameters:
file- local file that will be be used as data source or destinationbufferSize- size of the buffer returned during single read operation
-
-
Method Details
-
write
Description copied from interface:DataSinkWrites the specified buffer to this data sink.
Note:buffer.getOffset()might return -1 if the transfer mode used does not support data offsets, for example stream transfer mode.- Specified by:
writein interfaceDataSink- Parameters:
buffer- the data buffer to write.- Throws:
IOException- if an I/O error occurs.
-
read
In this implementation, each read() returns data sequentially.- Specified by:
readin interfaceDataSource- Returns:
- The data buffer read. Null, if there is no more data to be read.
- Throws:
IOException- if an I/O error occurs.
-
close
Closes the underlying file- Specified by:
closein interfaceDataSink- Specified by:
closein interfaceDataSource- Throws:
IOException- if an I/O error occurs.
-
totalSize
Description copied from interface:DataSourceOptional operation. Returns the total size, in bytes, of the data in this source. If the implementation is not able to provide a total size for the data source, it should return -1- Specified by:
totalSizein interfaceDataSource- Throws:
IOException- if an I/O exception occurs
-