Class DataSourceUtil
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.DataSourceUtil
-
public final class DataSourceUtil extends Object
Utility methods forDataSource.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseQuietly(DataSource dataSource)Closes aDataSource, suppressing anyIOExceptionthat may occur.static byte[]readExactly(DataSource dataSource, int length)Readslengthbytes from the specified openedDataSource, and returns a byte array containing the read data.static byte[]readToEnd(DataSource dataSource)Reads data from the specified openedDataSourceuntil it ends, and returns a byte array containing the read data.
-
-
-
Method Detail
-
readToEnd
public static byte[] readToEnd(DataSource dataSource) throws IOException
Reads data from the specified openedDataSourceuntil it ends, and returns a byte array containing the read data.- Parameters:
dataSource- The source from which to read.- Returns:
- The concatenation of all read data.
- Throws:
IOException- If an error occurs reading from the source.
-
readExactly
public static byte[] readExactly(DataSource dataSource, int length) throws IOException
Readslengthbytes from the specified openedDataSource, and returns a byte array containing the read data.- Parameters:
dataSource- The source from which to read.- Returns:
- The read data.
- Throws:
IOException- If an error occurs reading from the source.IllegalStateException- If the end of the source was reached beforelengthbytes could be read.
-
closeQuietly
public static void closeQuietly(@Nullable DataSource dataSource)Closes aDataSource, suppressing anyIOExceptionthat may occur.- Parameters:
dataSource- TheDataSourceto close.
-
-