docs/doc/reference/com/google/android/exoplayer2/upstream/cache/CacheWriter.html
Package com.google.android.exoplayer2.upstream.cache
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classCacheWriterextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
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.
Caching related utility methods.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static interface | CacheWriter.ProgressListener |
Deprecated.
Receives progress updates during cache operations. |
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static int | DEFAULT_BUFFER_SIZE_BYTES |
Deprecated.
Default buffer size to be used while caching. |
Constructors | Constructor | Description |
| --- | --- |
| CacheWriter(CacheDataSource dataSource, DataSpec dataSpec, byte[] temporaryBuffer, CacheWriter.ProgressListener progressListener) |
Deprecated.
|
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | cache() |
Deprecated.
Caches the requested data, skipping any that's already cached.
|
| void | cancel() |
Deprecated.
Cancels this writer's caching operation. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final int DEFAULT_BUFFER_SIZE_BYTES
Deprecated.
Default buffer size to be used while caching. See Also:Constant Field Values
-
public CacheWriter([CacheDataSource](CacheDataSource.html "class in com.google.android.exoplayer2.upstream.cache")dataSource,[DataSpec](../DataSpec.html "class in com.google.android.exoplayer2.upstream")dataSpec,
@Nullable
byte[] temporaryBuffer,
@Nullable[CacheWriter.ProgressListener](CacheWriter.ProgressListener.html "interface in com.google.android.exoplayer2.upstream.cache")progressListener)
Deprecated.
Parameters:dataSource - A CacheDataSource that writes to the target cache.dataSpec - Defines the data to be written.temporaryBuffer - A temporary buffer to be used during caching, or null if the writer should instantiate its own internal temporary buffer.progressListener - An optional progress listener.
-
public void cancel()
Deprecated.
Cancels this writer's caching operation. cache checks for cancelation frequently during execution, and throws an InterruptedIOException if it sees that the caching operation has been canceled.
-
@WorkerThread
public void cache()
throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")
Deprecated.
Caches the requested data, skipping any that's already cached.
If the CacheDataSource used by the writer has a PriorityTaskManager, then it's the responsibility of the caller to call PriorityTaskManager.add(int) to register with the manager before calling this method, and to call PriorityTaskManager.remove(int) afterwards to unregister. PriorityTaskManager.PriorityTooLowException will be thrown if the priority required by the CacheDataSource is not high enough for progress to be made.
This method may be slow and shouldn't normally be called on the main thread.
Throws:IOException - If an error occurs reading the data, or writing the data into the cache, or if the operation is canceled. If canceled, an InterruptedIOException is thrown. The method may be called again to continue the operation from where the error occurred.