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

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

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

Fs.fromJar介绍

暂无

代码示例

代码示例来源:origin: org.robolectric/robolectric

@Nonnull
private ResourcePath createRuntimeSdkResourcePath(DependencyResolver dependencyResolver) {
 try {
  Fs systemResFs = Fs.fromJar(dependencyResolver.getLocalArtifactUrl(sdkConfig.getAndroidSdkDependency()));
  Class<?> androidRClass = getRobolectricClassLoader().loadClass("android.R");
  Class<?> androidInternalRClass = getRobolectricClassLoader().loadClass("com.android.internal.R");
  // TODO: verify these can be loaded via raw-res path
  return new ResourcePath(androidRClass,
    systemResFs.join("raw-res/res"),
    systemResFs.join("raw-res/assets"),
    androidInternalRClass);
 } catch (ClassNotFoundException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: org.robolectric/resources

public static FsFile fromURL(URL url) {
 switch (url.getProtocol()) {
  case "file":
   return new FileFsFile(new File(url.getPath()));
  case "jar":
   String[] parts = url.getPath().split("!", 0);
   try {
    Fs fs = fromJar(new URL(parts[0]));
    return fs.join(parts[1].substring(1));
   } catch (MalformedURLException e) {
    throw new IllegalArgumentException(e);
   }
  default:
   throw new IllegalArgumentException("unsupported fs type for '" + url + "'");
 }
}

相关文章