本文整理匯總了Java中com.google.android.exoplayer2.util.Util.toByteArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Util.toByteArray方法的具體用法?Java Util.toByteArray怎麽用?Java Util.toByteArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.exoplayer2.util.Util
的用法示例。
在下文中一共展示了Util.toByteArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: executePost
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private byte[] executePost(String url, byte[] data, Map<String, String> requestProperties)
throws IOException {
HttpDataSource dataSource = dataSourceFactory.createDataSource();
if (requestProperties != null) {
for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) {
dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue());
}
}
DataSpec dataSpec = new DataSpec(Uri.parse(url), data, 0, 0, C.LENGTH_UNSET, null,
DataSpec.FLAG_ALLOW_GZIP);
DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
try {
return Util.toByteArray(inputStream);
} finally {
Util.closeQuietly(inputStream);
}
}
示例2: executePost
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
private static byte[] executePost(HttpDataSource.Factory dataSourceFactory, String url,
byte[] data, Map<String, String> requestProperties) throws IOException {
HttpDataSource dataSource = dataSourceFactory.createDataSource();
if (requestProperties != null) {
for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) {
dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue());
}
}
DataSpec dataSpec = new DataSpec(Uri.parse(url), data, 0, 0, C.LENGTH_UNSET, null,
DataSpec.FLAG_ALLOW_GZIP);
DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
try {
return Util.toByteArray(inputStream);
} finally {
Util.closeQuietly(inputStream);
}
}
示例3: getByteArray
import com.google.android.exoplayer2.util.Util; //導入方法依賴的package包/類
public static byte[] getByteArray(Instrumentation instrumentation, String fileName)
throws IOException {
return Util.toByteArray(getInputStream(instrumentation, fileName));
}