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

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

本文整理了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

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

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

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

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

  1. private static void assertCachedDataReadCorrect(CacheSpan cacheSpan) throws IOException {
  2. assertThat(cacheSpan.isCached).isTrue();
  3. byte[] expected = generateData(cacheSpan.key, (int) cacheSpan.position, (int) cacheSpan.length);
  4. FileInputStream inputStream = new FileInputStream(cacheSpan.file);
  5. try {
  6. assertThat(toByteArray(inputStream)).isEqualTo(expected);
  7. } finally {
  8. inputStream.close();
  9. }
  10. }

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

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

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

  1. /**
  2. * Asserts that the read data from {@code dataSource} specified by {@code dataSpec} is equal to
  3. * {@code expected} or not.
  4. *
  5. * @throws IOException If an error occurred reading from the Cache.
  6. */
  7. public static void assertReadData(
  8. DataSource dataSource, DataSpec dataSpec, byte[] expected, String messageToPrepend)
  9. throws IOException {
  10. DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
  11. byte[] bytes = null;
  12. try {
  13. bytes = Util.toByteArray(inputStream);
  14. } catch (IOException e) {
  15. // Ignore
  16. } finally {
  17. inputStream.close();
  18. }
  19. assertWithMessage(messageToPrepend).that(bytes).isEqualTo(expected);
  20. }

相关文章