Java Globus API: Class FileRandomIO
org.globus.ftp
Class FileRandomIO
java.lang.Object
|
+--org.globus.ftp.FileRandomIO
All Implemented Interfaces: DataSink , DataSource
public class FileRandomIO extends Object implements 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.
Method Summary
void
close ()
Closes the underlying file
Buffer
read ()
In this implementation, each read() returns data sequentially.
void
write (Buffer buffer)
Writes the specified buffer to this data sink.
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
bufferSize
protected int bufferSize
file
protected RandomAccessFile file
FileRandomIO
public FileRandomIO (RandomAccessFile file)
Behave like FileRandomIO(file, DEFAULT_BUFFER_SIZE)
Parameters: file - local file that will be be used as data source or
destination
FileRandomIO
public FileRandomIO (RandomAccessFile file,
int bufferSize)
Parameters: file - local file that will be be used as data source or
destinationbufferSize - size of the buffer returned during single
read operation
write
public void write (Buffer buffer)
throws IOException
Description copied from interface: DataSink
Writes 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: write in interface DataSink
Following copied from interface: org.globus.ftp.DataSink
Parameters: buffer - the data buffer to write.Throws: IOException - if an I/O error occurs.
read
public Buffer read ()
throws IOException
In this implementation, each read() returns data sequentially.
Specified by: read in interface DataSource
Following copied from interface: org.globus.ftp.DataSource
Returns: The data buffer read. Null, if there is
no more data to be read. Throws: IOException - if an I/O error occurs.
close
public void close ()
throws IOException
Closes the underlying file
Specified by: close in interface DataSink
Following copied from interface: org.globus.ftp.DataSink
Throws: IOException - if an I/O error occurs.