public class FileRandomIO extends Object implements DataSink, DataSource
Session.STREAM
transfer mode, only with GridFTPSession.EBLOCK
mode.Modifier and Type | Field and Description |
---|---|
protected int |
bufferSize |
static int |
DEFAULT_BUFFER_SIZE |
protected RandomAccessFile |
file |
protected long |
offset |
Constructor and Description |
---|
FileRandomIO(RandomAccessFile file)
Behave like FileRandomIO(file, DEFAULT_BUFFER_SIZE)
|
FileRandomIO(RandomAccessFile file,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying file
|
Buffer |
read()
In this implementation, each read() returns data sequentially.
|
long |
totalSize()
Optional operation.
|
void |
write(Buffer buffer)
Writes the specified buffer to this data sink.
|
public static final int DEFAULT_BUFFER_SIZE
protected int bufferSize
protected RandomAccessFile file
protected long offset
public FileRandomIO(RandomAccessFile file)
file
- local file that will be be used as data source or
destinationpublic FileRandomIO(RandomAccessFile file, int bufferSize)
file
- local file that will be be used as data source or
destinationbufferSize
- size of the buffer returned during single
read operationpublic void write(Buffer buffer) throws IOException
DataSink
buffer.getOffset()
might
return -1 if the transfer mode used does not support
data offsets, for example stream transfer mode.write
in interface DataSink
buffer
- the data buffer to write.IOException
- if an I/O error occurs.public Buffer read() throws IOException
read
in interface DataSource
IOException
- if an I/O error occurs.public void close() throws IOException
close
in interface DataSink
close
in interface DataSource
IOException
- if an I/O error occurs.public long totalSize() throws IOException
DataSource
totalSize
in interface DataSource
IOException
- if an I/O exception occursCopyright © 2016. All rights reserved.