jodd.io.FileUtil.toContainerFile()方法的使用及代码示例

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

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

FileUtil.toContainerFile介绍

[英]Returns a file of either a folder or a containing archive.
[中]返回文件夹或包含存档的文件。

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Scans URLs. If (#ignoreExceptions} is set, exceptions
 * per one URL will be ignored and loops continues.
 */
public ClassScanner scan(final URL... urls) {
  for (final URL url : urls) {
    final File file = FileUtil.toContainerFile(url);
    if (file == null) {
      if (!ignoreException) {
        throw new FindFileException("URL is not a valid file: " + url);
      }
    }
    else {
      filesToScan.add(file);
    }
  }
  return this;
}

代码示例来源:origin: oblac/jodd

/**
 * Specifies the search path. Throws an exception if URL is invalid.
 */
public FindFile searchPath(final URL searchPath) {
  File file = FileUtil.toContainerFile(searchPath);
  if (file == null) {
    throw new FindFileException("URL error: " + searchPath);
  }
  addPath(file);
  return this;
}

代码示例来源:origin: oblac/jodd

if (urls != null) {
  for (URL u : urls) {
    File f = FileUtil.toContainerFile(u);
    if ((f != null) && f.exists()) {
      try {

代码示例来源:origin: oblac/jodd

@Test
  void testWebJars() {
    URL url = ClassLoaderUtil.getResourceUrl("/META-INF/resources/webjars/jquery");

    File containerFile = FileUtil.toContainerFile(url);

    final Value<String> jqueryName = Value.of(null);

    ClassScanner classScanner = new ClassScanner() {
      @Override
      protected void onEntry(ClassPathEntry entryData) {
        if (entryData.name().endsWith("jquery.js")) {
          jqueryName.set(entryData.name());
        }
      }
    };

    classScanner.includeResources(true);
    classScanner.scan(containerFile);
    classScanner.start();

    assertNotNull(url);

    assertEquals("/META-INF/resources/webjars/jquery/2.2.4/jquery.js", jqueryName.get());
  }
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Scans URLs. If (#ignoreExceptions} is set, exceptions
 * per one URL will be ignored and loops continues.
 */
public ClassScanner scan(final URL... urls) {
  for (final URL url : urls) {
    final File file = FileUtil.toContainerFile(url);
    if (file == null) {
      if (!ignoreException) {
        throw new FindFileException("URL is not a valid file: " + url);
      }
    }
    else {
      filesToScan.add(file);
    }
  }
  return this;
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Specifies the search path. Throws an exception if URL is invalid.
 */
public FindFile searchPath(final URL searchPath) {
  File file = FileUtil.toContainerFile(searchPath);
  if (file == null) {
    throw new FindFileException("URL error: " + searchPath);
  }
  addPath(file);
  return this;
}

代码示例来源:origin: org.jodd/jodd-core

if (urls != null) {
  for (URL u : urls) {
    File f = FileUtil.toContainerFile(u);
    if ((f != null) && f.exists()) {
      try {

相关文章