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

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

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

Util.toByteArray介绍

[英]Converts the entirety of an InputStream to a byte array.
[中]将整个InputStream转换为字节数组。

代码示例

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

public static byte[] getByteArray(Context context, String fileName) throws IOException {
 return Util.toByteArray(getInputStream(context, fileName));
}

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

public static byte[] getByteArray(Context context, String fileName) throws IOException {
 return Util.toByteArray(getInputStream(context, fileName));
}

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

private static void assertCachedDataReadCorrect(CacheSpan cacheSpan) throws IOException {
 assertThat(cacheSpan.isCached).isTrue();
 byte[] expected = generateData(cacheSpan.key, (int) cacheSpan.position, (int) cacheSpan.length);
 FileInputStream inputStream = new FileInputStream(cacheSpan.file);
 try {
  assertThat(toByteArray(inputStream)).isEqualTo(expected);
 } finally {
  inputStream.close();
 }
}

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

DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
try {
 return Util.toByteArray(inputStream);
} catch (InvalidResponseCodeException e) {

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

/**
 * Asserts that the read data from {@code dataSource} specified by {@code dataSpec} is equal to
 * {@code expected} or not.
 *
 * @throws IOException If an error occurred reading from the Cache.
 */
public static void assertReadData(
  DataSource dataSource, DataSpec dataSpec, byte[] expected, String messageToPrepend)
  throws IOException {
 DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
 byte[] bytes = null;
 try {
  bytes = Util.toByteArray(inputStream);
 } catch (IOException e) {
  // Ignore
 } finally {
  inputStream.close();
 }
 assertWithMessage(messageToPrepend).that(bytes).isEqualTo(expected);
}

相关文章