org.modeshape.common.util.IoUtil.getResourceAsStream()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(193)

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

IoUtil.getResourceAsStream介绍

[英]Get the InputStream to the resource given by the supplied path. If a class loader is supplied, the method attempts to resolve the resource using the ClassLoader#getResourceAsStream(String) method; if the result is non-null, it is returned. Otherwise, if a class is supplied, this method attempts to resolve the resource using the Class#getResourceAsStream(String) method; if the result is non-null, it is returned. Otherwise, this method then uses the Class' ClassLoader to load the resource; if non-null, it is returned . Otherwise, this method looks for an existing and readable File at the path; if found, a buffered stream to that file is returned. Otherwise, this method attempts to parse the resource path into a valid URL; if this succeeds, the method attempts to open a stream to that URL. If all of these fail, this method returns null.
[中]获取由提供的路径给定的资源的InputStream。如果提供了类加载器,则该方法尝试使用类加载器#getResourceAsStream(String)方法解析资源;如果结果非空,则返回该结果。否则,如果提供了一个类,此方法将尝试使用类#getResourceAsStream(String)方法解析资源;如果结果非空,则返回该结果。否则,此方法将使用类的类加载器加载资源;如果不为null,则返回它。否则,此方法将在路径处查找现有的可读文件;如果找到,将返回到该文件的缓冲流。否则,此方法尝试将资源路径解析为有效URL;如果成功,该方法将尝试打开指向该URL的流。如果所有这些都失败,该方法将返回null。

代码示例

代码示例来源:origin: org.fcrepo/modeshape-jcr

private InputStream getInputStreamForFile( String cndFileString ) {
  return IoUtil.getResourceAsStream(cndFileString,
                   repository.environment().getClassLoader(this),
                   null);
}

代码示例来源:origin: ModeShape/modeshape

private InputStream getInputStreamForFile( String cndFileString ) {
  return IoUtil.getResourceAsStream(cndFileString,
                   repository.environment().getClassLoader(this),
                   null);
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

private InputStream getInitialContentFileStream( String workspaceName ) {
  String initialContentFileString = initialContentConfig.getInitialContentFile(workspaceName);
  InputStream stream = IoUtil.getResourceAsStream(initialContentFileString,
                          repository.environment().getClassLoader(this),
                          null);
  if (stream == null) {
    repository.warn(JcrI18n.cannotLoadInitialContentFile, initialContentFileString);
  }
  return stream;
}

代码示例来源:origin: ModeShape/modeshape

private InputStream getInitialContentFileStream( String workspaceName ) {
  String initialContentFileString = initialContentConfig.getInitialContentFile(workspaceName);
  InputStream stream = IoUtil.getResourceAsStream(initialContentFileString,
                          repository.environment().getClassLoader(this),
                          null);
  if (stream == null) {
    repository.warn(JcrI18n.cannotLoadInitialContentFile, initialContentFileString);
  }
  return stream;
}

相关文章