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

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

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

FileUtil.toURL介绍

[英]Converts file to URL in a correct way. Returns null in case of error.
[中]以正确的方式将文件转换为URL。出现错误时返回null

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Adds additional file or path to classpath during runtime.
 * @see #addUrlToClassPath(java.net.URL, ClassLoader)
 */
public static void addFileToClassPath(File path, ClassLoader classLoader) {
  try {
    addUrlToClassPath(FileUtil.toURL(path), classLoader);
  } catch (MalformedURLException muex) {
    throw new IllegalArgumentException("Invalid path: " + path, muex);
  }
}

代码示例来源:origin: redisson/redisson

/**
 * @see #findClass(String, java.net.URL[], ClassLoader)
 */
public static Class findClass(String className, File[] classPath, ClassLoader parent) {
  URL[] urls = new URL[classPath.length];
  for (int i = 0; i < classPath.length; i++) {
    File file = classPath[i];
    try {
      urls[i] = FileUtil.toURL(file);
    } catch (MalformedURLException ignore) {
    }
  }
  return findClass(className, urls, parent);
}

代码示例来源:origin: redisson/redisson

File file = (File) value;
try {
  return FileUtil.toURL(file);
} catch (MalformedURLException muex) {
  throw new TypeConversionException(value, muex);

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

File file = (File) value;
try {
  return FileUtil.toURL(file);
} catch (MalformedURLException muex) {
  throw new TypeConversionException(value, muex);

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

FileUtil.writeString(resourceFile, "RESOURCE CONTENT");
resourceFile.deleteOnExit();
URL[] urls = new URL[] {FileUtil.toURL(tempRoot)};
assertEquals(res, FileUtil.toURL(resourceFile));
assertEquals(res, FileUtil.toURL(resourceFile));
ecl.addLoaderOnlyRules("pckg.data");
res = ecl.getResource("pckg/data");
assertEquals(res, FileUtil.toURL(resourceFile));
ecl.addParentOnlyRules("pckg.data");
res = ecl.getResource("pckg/data");
ecl.addLoaderOnlyRules("pckg/data");
res = ecl.getResource("pckg/data");
assertEquals(res, FileUtil.toURL(resourceFile));
ecl.addParentOnlyRules("pckg.data");
res = ecl.getResource("pckg/data");

代码示例来源:origin: com.liferay.launchpad/common

public static URL[] toUrls(File... files) {
  URL[] urls = new URL[files.length];
  for (int i = 0; i < urls.length; i++) {
    File file = files[i];
    try {
      urls[i] = FileUtil.toURL(file);
    }
    catch (MalformedURLException e) {
      throw new IllegalArgumentException(e);
    }
  }
  return urls;
}

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

File file = (File) value;
try {
  return FileUtil.toURL(file);
} catch (MalformedURLException muex) {
  throw new TypeConversionException(value, muex);

相关文章