Modifier and Type | Class and Description |
---|---|
static class |
CacheDataSink.CacheDataSinkException
Thrown when IOException is encountered when writing data into sink.
|
DataSink.Factory
Constructor and Description |
---|
CacheDataSink(Cache cache,
long maxCacheFileSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the sink.
|
void |
open(DataSpec dataSpec)
Opens the sink to consume the specified data.
|
void |
write(byte[] buffer,
int offset,
int length)
Consumes the provided data.
|
public CacheDataSink(Cache cache, long maxCacheFileSize)
cache
- The cache into which data should be written.maxCacheFileSize
- The maximum size of a cache file, in bytes. If the sink is opened for
a DataSpec
whose size exceeds this value, then the data will be fragmented into
multiple cache files.public void open(DataSpec dataSpec) throws CacheDataSink.CacheDataSinkException
DataSink
open
in interface DataSink
dataSpec
- Defines the data to be consumed.CacheDataSink.CacheDataSinkException
public void write(byte[] buffer, int offset, int length) throws CacheDataSink.CacheDataSinkException
DataSink
write
in interface DataSink
buffer
- The buffer from which data should be consumed.offset
- The offset of the data to consume in buffer
.length
- The length of the data to consume, in bytes.CacheDataSink.CacheDataSinkException
public void close() throws CacheDataSink.CacheDataSinkException
DataSink
close
in interface DataSink
CacheDataSink.CacheDataSinkException