本文整理了Java中com.google.android.exoplayer2.util.Util.createTempFile()
方法的一些代码示例,展示了Util.createTempFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.createTempFile()
方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:createTempFile
[英]Creates a new empty file in the directory returned by Context#getCacheDir().
[中]在Context#getCacheDir()返回的目录中创建一个新的空文件。
代码示例来源:origin: google/ExoPlayer
/** Creates an empty directory in the directory returned by {@link Context#getCacheDir()}. */
public static File createTempDirectory(Context context, String prefix) throws IOException {
File tempFile = createTempFile(context, prefix);
tempFile.delete(); // Delete the temp file.
tempFile.mkdir(); // Create a directory with the same name.
return tempFile;
}
代码示例来源:origin: google/ExoPlayer
@Before
public void setUp() throws Exception {
tempFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
}
代码示例来源:origin: google/ExoPlayer
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
uri1 = Uri.parse("http://abc.com/media1");
uri2 = Uri.parse("http://abc.com/media2");
uri3 = Uri.parse("http://abc.com/media3");
dummyMainThread = new DummyMainThread();
actionFile = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
setUpDownloadManager(100);
}
代码示例来源:origin: google/ExoPlayer
@Test
public void testReloadCacheWithoutRelease() throws Exception {
SimpleCache simpleCache = getSimpleCache();
// Write data for KEY_1.
CacheSpan cacheSpan1 = simpleCache.startReadWrite(KEY_1, 0);
addCache(simpleCache, KEY_1, 0, 15);
simpleCache.releaseHoleSpan(cacheSpan1);
// Write and remove data for KEY_2.
CacheSpan cacheSpan2 = simpleCache.startReadWrite(KEY_2, 0);
addCache(simpleCache, KEY_2, 0, 15);
simpleCache.releaseHoleSpan(cacheSpan2);
simpleCache.removeSpan(simpleCache.getCachedSpans(KEY_2).first());
// Don't release the cache. This means the index file wont have been written to disk after the
// data for KEY_2 was removed. Move the cache instead, so we can reload it without failing the
// folder locking check.
File cacheDir2 = Util.createTempFile(RuntimeEnvironment.application, "ExoPlayerTest");
cacheDir2.delete();
cacheDir.renameTo(cacheDir2);
// Reload the cache from its new location.
simpleCache = new SimpleCache(cacheDir2, new NoOpCacheEvictor());
// Read data back for KEY_1.
CacheSpan cacheSpan3 = simpleCache.startReadWrite(KEY_1, 0);
assertCachedDataReadCorrect(cacheSpan3);
// Check the entry for KEY_2 was removed when the cache was reloaded.
assertThat(simpleCache.getCachedSpans(KEY_2)).isEmpty();
Util.recursiveDelete(cacheDir2);
}
代码示例来源:origin: google/ExoPlayer
File actionFile;
try {
actionFile = Util.createTempFile(context, "ExoPlayerTest");
} catch (IOException e) {
throw new RuntimeException(e);
内容来源于网络,如有侵权,请联系作者删除!