org.robolectric.res.Fs.getBytes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(155)

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

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;
}

相关文章