本文整理了Java中org.robolectric.res.Fs.getBytes()
方法的一些代码示例,展示了Fs.getBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fs.getBytes()
方法的具体详情如下:
包路径:org.robolectric.res.Fs
类名称:Fs
方法名:getBytes
暂无
代码示例来源:origin: robolectric/robolectric
public static Asset newFileAsset(FileTypedResource fileTypedResource) throws IOException {
_FileAsset fileAsset = new _FileAsset();
Path path = fileTypedResource.getPath();
fileAsset.mFileName = Fs.externalize(path);
fileAsset.mLength = Files.size(path);
fileAsset.mBuf = Fs.getBytes(path);
return fileAsset;
}
代码示例来源:origin: robolectric/robolectric
@HiddenApi @Implementation
public final InputStream openNonAsset(int cookie, String fileName, int accessMode) throws IOException {
final ResName resName = qualifyFromNonAssetFileName(fileName);
final FileTypedResource typedResource =
(FileTypedResource) resourceTable.getValue(resName, config);
if (typedResource == null) {
throw new IOException("Unable to find resource for " + fileName);
}
InputStream stream;
if (accessMode == AssetManager.ACCESS_STREAMING) {
stream = Fs.getInputStream(typedResource.getPath());
} else {
stream = new ByteArrayInputStream(Fs.getBytes(typedResource.getPath()));
}
if (RuntimeEnvironment.getApiLevel() >= P) {
Asset asset = Asset.newFileAsset(typedResource);
long assetPtr = Registries.NATIVE_ASSET_REGISTRY.register(asset);
// Camouflage the InputStream as an AssetInputStream so subsequent instanceof checks pass.
stream = ShadowAssetInputStream.createAssetInputStream(stream, assetPtr, realObject);
}
return stream;
}
内容来源于网络,如有侵权,请联系作者删除!