com.google.android.exoplayer2.util.Util.createTempFile()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中com.google.android.exoplayer2.util.Util.createTempFile()方法的一些代码示例,展示了Util.createTempFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createTempFile()方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:createTempFile

Util.createTempFile介绍

[英]Creates a new empty file in the directory returned by Context#getCacheDir().
[中]在Context#getCacheDir()返回的目录中创建一个新的空文件。

代码示例

代码示例来源:origin: google/ExoPlayer

  1. /** Creates an empty directory in the directory returned by {@link Context#getCacheDir()}. */
  2. public static File createTempDirectory(Context context, String prefix) throws IOException {
  3. File tempFile = createTempFile(context, prefix);
  4. tempFile.delete(); // Delete the temp file.
  5. tempFile.mkdir(); // Create a directory with the same name.
  6. return tempFile;
  7. }

代码示例来源:origin: google/ExoPlayer

  1. @Before
  2. public void setUp() throws Exception {
  3. tempFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
  4. }

代码示例来源:origin: google/ExoPlayer

  1. @Before
  2. public void setUp() throws Exception {
  3. MockitoAnnotations.initMocks(this);
  4. uri1 = Uri.parse("http://abc.com/media1");
  5. uri2 = Uri.parse("http://abc.com/media2");
  6. uri3 = Uri.parse("http://abc.com/media3");
  7. dummyMainThread = new DummyMainThread();
  8. actionFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
  9. setUpDownloadManager(100);
  10. }

代码示例来源:origin: google/ExoPlayer

  1. @Test
  2. public void testReloadCacheWithoutRelease() throws Exception {
  3. SimpleCache simpleCache = getSimpleCache();
  4. // Write data for KEY_1.
  5. CacheSpan cacheSpan1 = simpleCache.startReadWrite(KEY_1, 0);
  6. addCache(simpleCache, KEY_1, 0, 15);
  7. simpleCache.releaseHoleSpan(cacheSpan1);
  8. // Write and remove data for KEY_2.
  9. CacheSpan cacheSpan2 = simpleCache.startReadWrite(KEY_2, 0);
  10. addCache(simpleCache, KEY_2, 0, 15);
  11. simpleCache.releaseHoleSpan(cacheSpan2);
  12. simpleCache.removeSpan(simpleCache.getCachedSpans(KEY_2).first());
  13. // Don't release the cache. This means the index file wont have been written to disk after the
  14. // data for KEY_2 was removed. Move the cache instead, so we can reload it without failing the
  15. // folder locking check.
  16. File cacheDir2 = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
  17. cacheDir2.delete();
  18. cacheDir.renameTo(cacheDir2);
  19. // Reload the cache from its new location.
  20. simpleCache = new SimpleCache(cacheDir2, new NoOpCacheEvictor());
  21. // Read data back for KEY_1.
  22. CacheSpan cacheSpan3 = simpleCache.startReadWrite(KEY_1, 0);
  23. assertCachedDataReadCorrect(cacheSpan3);
  24. // Check the entry for KEY_2 was removed when the cache was reloaded.
  25. assertThat(simpleCache.getCachedSpans(KEY_2)).isEmpty();
  26. Util.recursiveDelete(cacheDir2);
  27. }

代码示例来源:origin: google/ExoPlayer

  1. File actionFile;
  2. try {
  3. actionFile = Util.createTempFile(context, "ExoPlayerTest");
  4. } catch (IOException e) {
  5. throw new RuntimeException(e);

相关文章