| Modifier and Type | Class and Description |
|---|---|
static class |
CacheDataSink.CacheDataSinkException
Thrown when IOException is encountered when writing data into sink.
|
| Constructor and Description |
|---|
CacheDataSink(Cache cache,
long maxCacheFileSize) |
CacheDataSink(Cache cache,
long maxCacheFileSize,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
DataSink. |
DataSink |
open(DataSpec dataSpec)
Opens the
DataSink 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 CacheDataSink(Cache cache, long maxCacheFileSize, int bufferSize)
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.bufferSize - The buffer size in bytes for writing to a cache file. A zero or negative
value disables buffering.public DataSink open(DataSpec dataSpec) throws CacheDataSink.CacheDataSinkException
DataSinkDataSink to consume the specified data. Calls to DataSink.open(DataSpec) and
DataSink.close() must be balanced.open in interface DataSinkdataSpec - Defines the data to be consumed.DataSink, for convenience.CacheDataSink.CacheDataSinkExceptionpublic void write(byte[] buffer,
int offset,
int length)
throws CacheDataSink.CacheDataSinkException
DataSinkwrite in interface DataSinkbuffer - 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.CacheDataSinkExceptionpublic void close()
throws CacheDataSink.CacheDataSinkException
DataSinkDataSink.close in interface DataSinkCacheDataSink.CacheDataSinkException