docs/doc/reference/com/google/android/exoplayer2/upstream/cache/CacheDataSink.html
Package com.google.android.exoplayer2.upstream.cache
All Implemented Interfaces:DataSink
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classCacheDataSinkextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[DataSink](../DataSink.html "interface in com.google.android.exoplayer2.upstream")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
Writes data into a cache.
If the DataSpec passed to open(DataSpec) has the length field set to C.LENGTH_UNSET and DataSpec.FLAG_DONT_CACHE_IF_LENGTH_UNKNOWN set, then write(byte[], int, int) calls are ignored.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static class | CacheDataSink.CacheDataSinkException |
Deprecated.
Thrown when an IOException is encountered when writing data to the sink.
|
| static class | CacheDataSink.Factory |
Deprecated.
DataSink.Factory for CacheDataSink instances.
|
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static int | DEFAULT_BUFFER_SIZE |
Deprecated.
Default buffer size in bytes.
|
| static long | DEFAULT_FRAGMENT_SIZE |
Deprecated.
Default fragmentSize recommended for caching use cases.
|
Constructors | Constructor | Description |
| --- | --- |
| CacheDataSink(Cache cache, long fragmentSize) |
Deprecated.
Constructs an instance using DEFAULT_BUFFER_SIZE.
|
| CacheDataSink(Cache cache, long fragmentSize, int bufferSize) |
Deprecated.
|
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | close() |
Deprecated.
Closes the sink.
|
| void | open(DataSpec dataSpec) |
Deprecated.
Opens the sink to consume the specified data.
|
| void | write(byte[] buffer, int offset, int length) |
Deprecated.
Consumes the provided data. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final long DEFAULT_FRAGMENT_SIZE
Deprecated.
Default fragmentSize recommended for caching use cases.
See Also:Constant Field Values
-
public static final int DEFAULT_BUFFER_SIZE
Deprecated.
Default buffer size in bytes. See Also:Constant Field Values
-
public CacheDataSink([Cache](Cache.html "interface in com.google.android.exoplayer2.upstream.cache")cache,
long fragmentSize)
Deprecated.
Constructs an instance using DEFAULT_BUFFER_SIZE.
Parameters:cache - The cache into which data should be written.fragmentSize - For requests that should be fragmented into multiple cache files, this is the maximum size of a cache file in bytes. If set to C.LENGTH_UNSET then no fragmentation will occur. Using a small value allows for finer-grained cache eviction policies, at the cost of increased overhead both on the cache implementation and the file system. Values under (2 * 1024 * 1024) are not recommended.
-
public CacheDataSink([Cache](Cache.html "interface in com.google.android.exoplayer2.upstream.cache")cache,
long fragmentSize,
int bufferSize)
Deprecated.
Parameters:cache - The cache into which data should be written.fragmentSize - For requests that should be fragmented into multiple cache files, this is the maximum size of a cache file in bytes. If set to C.LENGTH_UNSET then no fragmentation will occur. Using a small value allows for finer-grained cache eviction policies, at the cost of increased overhead both on the cache implementation and the file system. Values under (2 * 1024 * 1024) are not recommended.bufferSize - The buffer size in bytes for writing to a cache file. A zero or negative value disables buffering.
-
public void open([DataSpec](../DataSpec.html "class in com.google.android.exoplayer2.upstream")dataSpec)
throws[CacheDataSink.CacheDataSinkException](CacheDataSink.CacheDataSinkException.html "class in com.google.android.exoplayer2.upstream.cache")
Deprecated.
Description copied from interface: DataSink
Opens the sink to consume the specified data.
Note: If an IOException is thrown, callers must still call DataSink.close() to ensure that any partial effects of the invocation are cleaned up.
Specified by:open in interface DataSinkParameters:dataSpec - Defines the data to be consumed.Throws:CacheDataSink.CacheDataSinkException
-
public void write(byte[] buffer,
int offset,
int length)
throws[CacheDataSink.CacheDataSinkException](CacheDataSink.CacheDataSinkException.html "class in com.google.android.exoplayer2.upstream.cache")
Deprecated.
Description copied from interface: DataSink
Consumes the provided data.
Specified by:write in interface DataSinkParameters: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.Throws:CacheDataSink.CacheDataSinkException
-
public void close()
throws[CacheDataSink.CacheDataSinkException](CacheDataSink.CacheDataSinkException.html "class in com.google.android.exoplayer2.upstream.cache")
Deprecated.
Description copied from interface: DataSink
Closes the sink.
Note: This method must be called even if the corresponding call to DataSink.open(DataSpec) threw an IOException. See DataSink.open(DataSpec) for more details.
Specified by:close in interface DataSinkThrows:CacheDataSink.CacheDataSinkException